Class: EYCli::Command::Show

Inherits:
Base
  • Object
show all
Defined in:
lib/ey_cli/commands/show.rb

Defined Under Namespace

Classes: ShowParser

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#run

Constructor Details

#initializeShow

Returns a new instance of Show.



4
5
6
# File 'lib/ey_cli/commands/show.rb', line 4

def initialize
  @apps = EYCli::Controller::Apps.new
end

Instance Method Details

#helpObject



48
49
50
51
52
53
54
# File 'lib/ey_cli/commands/show.rb', line 48

def help
  <<-EOF

Show information and status of an application. If a name is not supplied it assumes the current directory as application base.
Usage: `ey_cli show app_name'
EOF
end

#info(app) ⇒ Object



16
17
18
19
20
21
# File 'lib/ey_cli/commands/show.rb', line 16

def info(app)
  %Q{
#{app.name}:
  - Info:
     + git repository: #{app.git_repository}}
end

#invokeObject



8
9
10
11
12
13
14
# File 'lib/ey_cli/commands/show.rb', line 8

def invoke
  app = @apps.fetch_app(nil, options)
  if app
    EYCli.term.say info(app)
    EYCli.term.say(status(app)) if app.environments
  end
end

#options_parserObject



56
57
58
# File 'lib/ey_cli/commands/show.rb', line 56

def options_parser
  ShowParser.new
end

#status(app) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ey_cli/commands/show.rb', line 23

def status(app)
  status = %Q{

  - Status per environment:}
  app.environments.each do |env|
    status << %Q{
     + #{env.name}:
  - environment: #{env.framework_env}
  - stack:       #{env.app_server_stack_name}
  - status:      #{env.instance_status}}

    if env.instances
      status << %Q{
  - instances:}
      env.instances.each do |instance|
        status << %Q{
     + #{instance.role}:
        - Amazon ID: #{instance.amazon_id}
        - status:    #{instance.status}}
      end
    end
  end
  status
end