class Sfctl::Commands::Account::Assignments
Public Class Methods
new(options)
click to toggle source
# File lib/sfctl/commands/account/assignments.rb, line 10 def initialize(options) @options = options @pastel = Pastel.new(enabled: !@options['no-color']) end
Public Instance Methods
execute(output: $stdout)
click to toggle source
# File lib/sfctl/commands/account/assignments.rb, line 15 def execute(output: $stdout) return unless config_present?(output) success, data = Starfish::Client.account_assignments(@options['starfish-host'], @options['all'], access_token) unless success output.puts @pastel.red('Something went wrong. Unable to fetch assignments') return end print_assignments(data['assignments'], output) end
Private Instance Methods
print_assignments(assignments, output)
click to toggle source
# File lib/sfctl/commands/account/assignments.rb, line 41 def print_assignments(assignments, output) assignments.each do |assignment| header = ["Assignment: #{assignment['name']}"] table = ::TTY::Table.new header: header, rows: rows(assignment) output.print table.render(:unicode, padding: [0, 1], multiline: true) output.puts end end
rows(assignment)
click to toggle source
# File lib/sfctl/commands/account/assignments.rb, line 30 def rows(assignment) [[ <<~HEREDOC Service: #{assignment['service']} Start: #{assignment['start_date']} End: #{assignment['end_date']} Budget: #{assignment['budget']} #{assignment['unit']} HEREDOC ]] end