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



63
64
65
66
67
68
69
# File 'lib/ey_cli/commands/show.rb', line 63

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.repository_uri}}
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



71
72
73
# File 'lib/ey_cli/commands/show.rb', line 71

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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}
  - app stack:    #{env.app_server_stack_name}
  - IP address:   #{env.load_balancer_ip_address}
  - status:       #{env.instance_status}}

    if deploy = env.last_deployment(app)
      status << %Q{
  + last deploy info:
     - commit:          #{deploy.commit}
     - created at:      #{deploy.created_at}
     - finished at:     #{deploy.finished_at}
     - migrated:        #{deploy.migrate}}
     if deploy.migrate
       status << %Q{
     - migrate command: #{deploy.migrate_command}}
     end
    end

    if env.instances
      status << %Q{

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