class CommandKit::Commands::Help

The default help command.

@api semipublic

Public Instance Methods

run(command=nil) click to toggle source

Prints the given commands `–help` output or lists registered commands.

@param [String, nil] command

The given command name, or `nil` if no command name was given.
# File lib/command_kit/commands/help.rb, line 25
def run(command=nil)
  case command
  when nil
    parent_command.help
  else
    if (subcommand = parent_command.command(command))
      unless subcommand.respond_to?(:help)
        raise(TypeError,"#{subcommand.inspect} must define a #help method")
      end

      subcommand.help
    else
      print_error "#{command_name}: unknown command: #{command}"
      exit(1)
    end
  end
end