Class: Scorm::Command::Help
- Inherits:
-
Base
- Object
- Base
- Scorm::Command::Help
show all
- Defined in:
- lib/scorm/commands/help.rb
Defined Under Namespace
Classes: HelpGroup
Instance Attribute Summary
Attributes inherited from Base
#args, #autodetected_package
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#display, #error, #extract_option, #extract_package, #initialize
Class Method Details
.create_default_groups! ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/scorm/commands/help.rb', line 31
def self.create_default_groups!
group 'Commands' do |group|
group.command 'help', 'show this usage'
group.command 'version', 'show the gem version'
group.space
group.command 'create <name>', 'create a new package skeleton'
group.command 'bundle [<path to directory>]', 'creates a package from the current directory'
group.command 'check <path to zip file>', 'runs a test suite against your package'
group.command 'extract <path to zip file>', 'extracts and checks the specified package'
end
end
|
.group(title, &block) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/scorm/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/scorm/commands/help.rb', line 19
def self.groups
@groups ||= []
end
|
Instance Method Details
#index ⇒ Object
43
44
45
|
# File 'lib/scorm/commands/help.rb', line 43
def index
display usage
end
|
#usage ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/scorm/commands/help.rb', line 47
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 + <<-EOTXT
=== Example
scorm create mypackage
cd mypackage
scorm check
scorm bundle
scorm extract mypackage.zip
EOTXT
end
|