Sha256: e11bde924515ca06d9d95765180a81bcbec7b1ad4c450cea92fb0c9951261c11

Contents?: true

Size: 938 Bytes

Versions: 8

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

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

8 entries across 8 versions & 2 rubygems

Version Path
jekyll-3.6.3 lib/jekyll/commands/help.rb
jekyll-3.7.0 lib/jekyll/commands/help.rb
jekyll-docs-3.6.2 lib/jekyll/commands/help.rb
jekyll-docs-3.6.1 lib/jekyll/commands/help.rb
jekyll-3.6.2 lib/jekyll/commands/help.rb
jekyll-3.6.1 lib/jekyll/commands/help.rb
jekyll-3.6.0 lib/jekyll/commands/help.rb
jekyll-3.6.0.pre.beta1 lib/jekyll/commands/help.rb