Class: Leg::Commands::Help
Instance Attribute Summary
Attributes inherited from BaseCommand
#config, #opts
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
#git_to_litdiff!, inherited, #initialize, #litdiff_to_git!, #needs!, #output, #parseopts!
Class Method Details
.name ⇒ Object
4
5
6
|
# File 'lib/leg/commands/help.rb', line 4
def self.name
"help"
end
|
.summary ⇒ Object
8
9
10
11
|
# File 'lib/leg/commands/help.rb', line 8
def self.summary
"Print out list of commands, or get help\n" +
"on a specific command."
end
|
.usage ⇒ Object
13
14
15
|
# File 'lib/leg/commands/help.rb', line 13
def self.usage
"[<command>]"
end
|
Instance Method Details
#run ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/leg/commands/help.rb', line 20
def run
if @args.empty?
puts "<< Hello! I am leg, version #{Leg::VERSION} >>"
puts
puts "Usage: leg <command> [args...]"
puts
puts "Commands:"
Leg::Commands::LIST.each do |cmd|
puts " #{cmd.name} #{cmd.usage}"
cmd.summary.split("\n").each do |line|
puts " #{line}"
end
end
puts
puts "For more help on a specific command, run `leg help <command>`."
elsif cmd = Leg::Commands::LIST.find { |cmd| cmd.name == @args.first }
cmd.new(["--help"], @config)
else
puts "There is no '#{@args.first}' command."
end
end
|
#setopts!(o) ⇒ Object
17
18
|
# File 'lib/leg/commands/help.rb', line 17
def setopts!(o)
end
|