Module: Aptible::CLI::Subcommands::Domains

Included in:
Agent
Defined in:
lib/aptible/cli/subcommands/domains.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/aptible/cli/subcommands/domains.rb', line 7

def self.included(thor)
  thor.class_eval do
    include Helpers::Operation
    include Helpers::App

    desc 'domains',
         "Print an app's current virtual domains - DEPRECATED"
    app_options
    option :verbose, aliases: '-v'
    def domains
      deprecated 'This command is deprecated in favor of endpoints:list'
      app = ensure_app(options)
      print_vhosts(app) do |vhost|
        if options[:verbose]
          "#{vhost.virtual_domain} -> #{vhost.external_host}"
        else
          vhost.virtual_domain
        end
      end
    end

    private

    def print_vhosts(app)
      (app.vhosts || []).each do |vhost|
        say yield(vhost)
      end
    end
  end
end