Class: Q::Help
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #execute(shortcut, terms) ⇒ Object
- #help(shortcut, terms) ⇒ Object
-
#initialize ⇒ Help
constructor
A new instance of Help.
Methods inherited from Command
Constructor Details
#initialize ⇒ Help
Returns a new instance of Help.
3 4 5 |
# File 'lib/q/commands/help.rb', line 3 def initialize super("COMMAND -- print help for COMMAND") end |
Instance Method Details
#execute(shortcut, terms) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/q/commands/help.rb', line 7 def execute(shortcut, terms) shortcut = terms.shift.to_sym unless terms.empty? if command = Q.commands[shortcut] command.help(shortcut, terms) else shortcut.to_s + ": unknown command" end end |
#help(shortcut, terms) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/q/commands/help.rb', line 16 def help(shortcut, terms) ([ %q{Usage: q [SHORTCUT] [TERM] ...}, %q{Perform the command specified by SHORTCUT for the specified TERMs.}, "" ] + Q.unique_commands.map{ |command| " " + command.usage }.sort).join($/) end |