Sha256: de20ae781b6560bae53d3b794a6997aee37cf0ad3ff06e84057110ea704d4eb0

Contents?: true

Size: 990 Bytes

Versions: 15

Compression:

Stored size: 990 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

15 entries across 15 versions & 1 rubygems

Version Path
jekyll-4.4.1 lib/jekyll/commands/help.rb
jekyll-4.4.0 lib/jekyll/commands/help.rb
jekyll-4.3.4 lib/jekyll/commands/help.rb
jekyll-4.3.3 lib/jekyll/commands/help.rb
jekyll-4.3.2 lib/jekyll/commands/help.rb
jekyll-4.3.1 lib/jekyll/commands/help.rb
jekyll-4.3.0 lib/jekyll/commands/help.rb
jekyll-4.2.2 lib/jekyll/commands/help.rb
jekyll-4.2.0 lib/jekyll/commands/help.rb
jekyll-4.1.1 lib/jekyll/commands/help.rb
jekyll-4.1.0 lib/jekyll/commands/help.rb
jekyll-4.0.1 lib/jekyll/commands/help.rb
jekyll-4.0.0 lib/jekyll/commands/help.rb
jekyll-4.0.0.pre.beta1 lib/jekyll/commands/help.rb
jekyll-4.0.0.pre.alpha1 lib/jekyll/commands/help.rb