Sha256: 5c8fa86382ead12df772a73e868f6d25ff9a83173defe79b0c61b7535da6f4c1

Contents?: true

Size: 976 Bytes

Versions: 20

Compression:

Stored size: 976 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?
                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

        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

20 entries across 20 versions & 1 rubygems

Version Path
jekyll-3.10.0 lib/jekyll/commands/help.rb
jekyll-3.9.5 lib/jekyll/commands/help.rb
jekyll-3.9.4 lib/jekyll/commands/help.rb
jekyll-3.9.3 lib/jekyll/commands/help.rb
jekyll-3.9.2 lib/jekyll/commands/help.rb
jekyll-3.9.1 lib/jekyll/commands/help.rb
jekyll-3.9.0 lib/jekyll/commands/help.rb
jekyll-3.8.7 lib/jekyll/commands/help.rb
jekyll-3.8.6 lib/jekyll/commands/help.rb
jekyll-3.8.5 lib/jekyll/commands/help.rb
jekyll-3.8.4 lib/jekyll/commands/help.rb
jekyll-3.7.4 lib/jekyll/commands/help.rb
jekyll-3.8.3 lib/jekyll/commands/help.rb
jekyll-3.8.2 lib/jekyll/commands/help.rb
jekyll-3.8.1 lib/jekyll/commands/help.rb
jekyll-3.8.0 lib/jekyll/commands/help.rb
jekyll-3.8.0.pre.rc2 lib/jekyll/commands/help.rb
jekyll-3.8.0.pre.rc1 lib/jekyll/commands/help.rb
jekyll-3.7.3 lib/jekyll/commands/help.rb
jekyll-3.7.2 lib/jekyll/commands/help.rb