Sha256: 3f4ad34e0aecce91877f7e919f942206465c69c85a493593c1ec99ae9ab34164

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 KB

Contents

require 'ey-core/cli/subcommand'

module Ey
  module Core
    module Cli
      class Servers < Subcommand
        title "servers"
        summary "List servers you have access to"

        option :account,
          short: 'c',
          long: 'account',
          description: 'Filter by account name or id',
          argument: 'Account'

        option :environment,
          short: "-e",
          long: "environment",
          description: "Filter by environment.",
          argument: "environment"

        def handle
          puts TablePrint::Printer.
            new(servers, [{id: {width: 10}}, :role, :provisioned_id]).
            table_print
        end

        private
        def servers
          if option(:account)
            core_client.servers.all(account: core_account)
          elsif environment = option(:environment)
            (core_client.environments.get(environment) || core_client.environments.first(name: environment)).servers.all
          else
            core_client.servers.all
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ey-core-3.4.4 lib/ey-core/cli/servers.rb
ey-core-3.4.2 lib/ey-core/cli/servers.rb
ey-core-3.4.1 lib/ey-core/cli/servers.rb
ey-core-3.4.0 lib/ey-core/cli/servers.rb
ey-core-3.3.1 lib/ey-core/cli/servers.rb
ey-core-3.3.0 lib/ey-core/cli/servers.rb
ey-core-3.2.6 lib/ey-core/cli/servers.rb
ey-core-3.2.5 lib/ey-core/cli/servers.rb
ey-core-3.2.4 lib/ey-core/cli/servers.rb
ey-core-3.2.3 lib/ey-core/cli/servers.rb
ey-core-3.2.2 lib/ey-core/cli/servers.rb
ey-core-3.2.1 lib/ey-core/cli/servers.rb
ey-core-3.2.0 lib/ey-core/cli/servers.rb
ey-core-3.1.11 lib/ey-core/cli/servers.rb
ey-core-3.1.10 lib/ey-core/cli/servers.rb
ey-core-3.1.9 lib/ey-core/cli/servers.rb
ey-core-3.1.8 lib/ey-core/cli/servers.rb
ey-core-3.1.7 lib/ey-core/cli/servers.rb
ey-core-3.1.6 lib/ey-core/cli/servers.rb
ey-core-3.1.5 lib/ey-core/cli/servers.rb