Sha256: cb3e2ae1360f1602a99f396a0b0a03ca3dc755cd519a53bd113b247f01dd8d70

Contents?: true

Size: 1.48 KB

Versions: 10

Compression:

Stored size: 1.48 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ServiceCommand
      class ShowSubcommand < Cri::CommandRunner
        include ThreeScaleToolbox::Command

        FIELDS = %w[
          id name state system_name end_user_registration_required
          backend_version deployment_option support_email description
          created_at updated_at
        ]

        def self.command
          Cri::Command.define do
            name        'show'
            usage       'show <remote> <service-id_or_system-name>'
            summary     'Show the information of a service'
            description "Show the information of a service"

            ThreeScaleToolbox::CLI.output_flag(self)
            param   :remote
            param   :service_id_or_system_name

            runner ShowSubcommand
          end
        end

        def run
          printer.print_record service.attrs
        end

        private

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

        def ref
          @ref ||= arguments[:service_id_or_system_name]
        end

        def service
          @service ||= find_service
        end

        def find_service
          Entities::Service::find(remote: remote, ref: ref).tap do |svc|
            raise ThreeScaleToolbox::Error, "Service #{ref} does not exist" if svc.nil?
          end
        end

        def printer
          options.fetch(:output, CLI::CustomTablePrinter.new(FIELDS))
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/service_command/show_command.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/service_command/show_command.rb