class Jekyll::Commands::Help

Public Class Methods

init_with_program(prog) click to toggle source
# File lib/jekyll/commands/help.rb, line 7
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
      if args.empty?
        Jekyll.logger.info prog.to_s
      elsif prog.has_command? cmd
        Jekyll.logger.info prog.commands[cmd].to_s
      else
        invalid_command(prog, cmd)
        abort
      end
    end
  end
end
invalid_command(prog, cmd) click to toggle source
# File lib/jekyll/commands/help.rb, line 26
def invalid_command(prog, cmd)
  Jekyll.logger.error "Error:",
                      "Hmm... we don't know what the '#{cmd}' command is."
  Jekyll.logger.info  "Valid commands:", prog.commands.keys.join(", ")
end