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
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