Class: Speedflow::Commands::Help
- Inherits:
-
Speedflow::Command
- Object
- Speedflow::Command
- Speedflow::Commands::Help
- Extended by:
- Message
- Defined in:
- lib/speedflow/commands/help.rb
Overview
Help command
Class Method Summary collapse
-
.init_with_program(prog) ⇒ Object
Init command with program.
-
.process(cmd, prog, args) ⇒ Object
Process command.
Methods included from Message
error, info, message, notice, success
Methods inherited from Speedflow::Command
config_from_fresh_options, config_from_options, execute_from_option, inherited, invalid_command, subclasses
Class Method Details
.init_with_program(prog) ⇒ Object
Init command with program.
prog - the programm
Returns nothing.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/speedflow/commands/help.rb', line 13 def init_with_program(prog) prog.command(:help) do |c| c.syntax 'help [subcommand]' c.description 'Show the help message, optionally for a given ' \ 'subcommand.' c.action do |args, _| cmd = (args.first || '').to_sym process(cmd, prog, args) end end end |
.process(cmd, prog, args) ⇒ Object
Process command.
cmd - Command. prog - Program. args - Arguments.
Returns nothing.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/speedflow/commands/help.rb', line 32 def process(cmd, prog, args) if args.empty? puts prog elsif prog.has_command? cmd puts prog.commands[cmd] else invalid_command(cmd) abort end end |