class Speedflow::Commands::Help

Help command

Public Class Methods

init_with_program(prog) click to toggle source

Init command with program.

prog - the programm

Returns nothing.

# 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) click to toggle source

Process command.

cmd - Command. prog - Program. args - Arguments.

Returns nothing.

# 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