Class: Dctl::Command::StatusCommand

Inherits:
NonRedirectibleCommand show all
Defined in:
lib/dctl/command.rb

Instance Method Summary collapse

Methods inherited from NonRedirectibleCommand

#initialize

Methods inherited from SmartCommand

#initialize

Constructor Details

This class inherits a constructor from Dctl::Command::NonRedirectibleCommand

Instance Method Details

#descriptionObject



102
103
104
# File 'lib/dctl/command.rb', line 102

def description
  "Get the state of specified applications (one or more)."
end

#execute(cmd_parser, args) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/dctl/command.rb', line 106

def execute(cmd_parser, args)
  if args.length > 0
    args.each { |cmd| puts status(cmd) rescue puts $! }
  else
    Dir[File.join($DIR, '*.pid')].collect { |p| File.basename(p, '.*')}.each { |cmd| puts status(cmd) } # BUG ! if cmd not in PATH !
  end
end

#status(cmd) ⇒ Object



114
115
116
# File 'lib/dctl/command.rb', line 114

def status(cmd)
  "#{cmd}: #{File.basename(Dctl::Daemon.new(cmd, $DIR, false).status.id2name)}"
end