Sha256: ea83ed2860cab1e2a1e0af9089285193160d2a25d591d42427d9dbad493759f8

Contents?: true

Size: 1.24 KB

Versions: 16

Compression:

Stored size: 1.24 KB

Contents

require 'byebug/command'
require 'byebug/errors'

module Byebug
  #
  # Ask for help from byebug's prompt.
  #
  class HelpCommand < Command
    self.allow_in_control = true
    self.allow_in_post_mortem = true

    def self.regexp
      /^\s* h(?:elp)? (?:\s+(\S+))? (?:\s+(\S+))? \s*$/x
    end

    def self.description
      <<-EOD
        h[elp][ <cmd>[ <subcmd>]]

        #{short_description}

        help                -- prints a summary of all commands
        help <cmd>          -- prints help on command <cmd>
        help <cmd> <subcmd> -- prints help on <cmd>'s subcommand <subcmd>
      EOD
    end

    def self.short_description
      'Helps you using byebug'
    end

    def execute
      return help_for_all unless @match[1]

      return help_for(@match[1], command) unless @match[2]

      help_for(@match[2], subcommand)
    end

    private

    def help_for_all
      puts(processor.command_list.to_s)
    end

    def help_for(input, cmd)
      raise CommandNotFound.new(input, command) unless cmd

      puts(cmd.help)
    end

    def command
      @command ||= processor.command_list.match(@match[1])
    end

    def subcommand
      return unless command

      @subcommand ||= command.subcommand_list.match(@match[2])
    end
  end
end

Version data entries

16 entries across 15 versions & 3 rubygems

Version Path
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/lib/byebug/commands/help.rb
tdiary-5.0.6 vendor/bundle/gems/byebug-9.1.0/lib/byebug/commands/help.rb
byebug-9.1.0 lib/byebug/commands/help.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/help.rb
tdiary-5.0.5 vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/help.rb
tdiary-5.0.4 vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/help.rb
byebug-9.0.6 lib/byebug/commands/help.rb
byebug-9.0.5 lib/byebug/commands/help.rb
byebug-9.0.4 lib/byebug/commands/help.rb
byebug-9.0.3 lib/byebug/commands/help.rb
byebug-9.0.2 lib/byebug/commands/help.rb
byebug-9.0.1 lib/byebug/commands/help.rb
byebug-9.0.0 lib/byebug/commands/help.rb
byebug-8.2.5 lib/byebug/commands/help.rb
byebug-8.2.4 lib/byebug/commands/help.rb
byebug-8.2.3 lib/byebug/commands/help.rb