Class: ThreeScaleToolbox::Commands::ApplicationCommand::List::ListSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/application_command/list_command.rb

Constant Summary collapse

FIELDS_TO_SHOW =
%w[id name state enabled account_id service_id plan_id].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/3scale_toolbox/commands/application_command/list_command.rb', line 10

def self.command
  Cri::Command.define do
    name        'list'
    usage       'list [opts] <remote>'
    summary     'list applications'
    description 'List applications'

    option      nil, :account, 'Filter by account', argument: :required
    option      nil, :service, 'Filter by service', argument: :required
    option      nil, :plan, 'Filter by application plan. Service option required', argument: :required
    ThreeScaleToolbox::CLI.output_flag(self)

    param       :remote

    runner ListSubcommand
  end
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/3scale_toolbox/commands/application_command/list_command.rb', line 28

def run
  validate_option_params

  applications = if 
                   .applications
                 elsif option_service && option_plan
                   plan.applications
                 elsif option_service
                   service.applications
                 else
                   
                 end

  printer.print_collection applications.map(&:attrs)
end