Sha256: dd77f102c414ce7aa30ca49db46d2410bdfe14abb52e07c08840bcc71421d476

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ServiceCommand
      module List
        class ListSubcommand < Cri::CommandRunner
          include ThreeScaleToolbox::Command

          def self.command
            Cri::Command.define do
              name        'list'
              usage       'list <remote>'
              summary     'List all services'
              description 'List all services'
              runner ListSubcommand

              param :remote
            end
          end

          def run
            print_header
            print_data
          end

          private

          SERVICE_FIELDS_TO_SHOW = %w[id name system_name]

          def services
            @services ||= remote.list_services()
          end

          def remote
            @remote ||= threescale_client(arguments[:remote])
          end

          def print_header
            puts SERVICE_FIELDS_TO_SHOW.map { |e| e.upcase }.join("\t")
          end

          def print_data
            services.each do |service|
              puts SERVICE_FIELDS_TO_SHOW.map { |field| service.fetch(field, '(empty)') }.join("\t")
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
3scale_toolbox-0.15.0 lib/3scale_toolbox/commands/service_command/list_command.rb
3scale_toolbox-0.14.0 lib/3scale_toolbox/commands/service_command/list_command.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/commands/service_command/list_command.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/commands/service_command/list_command.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/commands/service_command/list_command.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/commands/service_command/list_command.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/commands/service_command/list_command.rb