Sha256: 2e846a9b79d11d5aa6ec001cecf7ffd5a348cf741b8997f8a6c067ca75292c02

Contents?: true

Size: 893 Bytes

Versions: 24

Compression:

Stored size: 893 Bytes

Contents

module Jekyll
  module Commands
    class Help < Command
      class << self

        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?
                puts prog
              elsif prog.has_command? cmd
                puts prog.commands[cmd]
              else
                invalid_command(prog, cmd)
                abort
              end
            end
          end
        end

        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

      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
jekyll-2.5.1 lib/jekyll/commands/help.rb
jekyll-2.5.0 lib/jekyll/commands/help.rb
jekyll-2.4.0 lib/jekyll/commands/help.rb
jekyll-2.3.0 lib/jekyll/commands/help.rb