Method: VMC::Cli::Command::Apps#list

Defined in:
lib/cli/commands/apps.rb

#listObject Also known as: apps



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cli/commands/apps.rb', line 19

def list
  apps = client.apps
  apps.sort! {|a, b| a[:name] <=> b[:name] }
  return display JSON.pretty_generate(apps || []) if @options[:json]

  display "\n"
  return display "No Applications" if apps.nil? || apps.empty?
  
  infra_supported = !apps.detect { |a| a[:infra] }.nil?

  apps_table = table do |t|
    t.headings = 'Application', '# ', 'Health', 'URLS', 'Services'
    t.headings << 'In' if infra_supported
    apps.each do |app|
      a = [app[:name], app[:instances], health(app), app[:uris].join(', '), app[:services].join(', ')]
      if infra_supported
        a << ( app[:infra] ? app[:infra][:provider] : "   " )
      end
      t << a  
    end
  end
  display apps_table
end