Class: Cloudkick::Command::Help
- Inherits:
-
Base
- Object
- Base
- Cloudkick::Command::Help
show all
- Defined in:
- lib/cloudkick/commands/help.rb
Defined Under Namespace
Classes: HelpGroup
Instance Attribute Summary
Attributes inherited from Base
#args
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#client, #credentials, #display, #extract_option, #initialize
Class Method Details
.create_default_groups! ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/cloudkick/commands/help.rb', line 31
def self.create_default_groups!
group 'Commands' do |group|
group.command 'help', 'show this usage'
group.space
group.command 'pssh --query <query> ' \
'<command> ' \
'[--username <username>] ',
'parallel ssh your nodes'
end
end
|
.group(title, &block) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/cloudkick/commands/help.rb', line 23
def self.group(title, &block)
groups << begin
group = HelpGroup.new(title)
yield group
group
end
end
|
.groups ⇒ Object
19
20
21
|
# File 'lib/cloudkick/commands/help.rb', line 19
def self.groups
@groups ||= []
end
|
Instance Method Details
#index ⇒ Object
42
43
44
|
# File 'lib/cloudkick/commands/help.rb', line 42
def index
display usage
end
|
#usage ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/cloudkick/commands/help.rb', line 46
def usage
longest_command_length = self.class.groups.map do |group|
group.map { |g| g.first.length }
end.flatten.max
self.class.groups.inject(StringIO.new) do |output, group|
output.puts "=== %s" % group.title
output.puts
group.each do |command, description|
if command.empty?
output.puts
else
output.puts "%-*s # %s" % [longest_command_length, command, description]
end
end
output.puts
output
end.string
end
|