Sha256: b8dd16a5390249db403ceb897858a69183641d0b295a8d4cc6092dc13a51dd07

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

module Byebug
  #
  # Ask for help from byebug's prompt.
  #
  class HelpCommand < Command
    include Columnize

    self.allow_in_control = true

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

    def execute
      if @match[1]
        args = @match[1].split
        cmds = @state.commands.select { |cmd| cmd.names.include?(args[0]) }
        if cmds.empty?
          return errmsg("Undefined command: \"#{args[0]}\". Try \"help\"")
        end

        return puts(cmds.map { |cmd| cmd.help(args[1..-1]) }.join("\n"))
      end

      puts "byebug help v#{VERSION}" unless Setting[:testing]
      puts "Type \"help <command-name>\" for help on a specific command\n"
      puts 'Available commands:'
      cmds = @state.commands.map { |cmd| cmd.names }.flatten.uniq.sort
      puts columnize(cmds, Setting[:width])
    end

    class << self
      def names
        %w(help)
      end

      def description
        %(h[elp][ <command>[ <subcommand>]]

          "help" alone prints this help.
          "help <command>" prints help on <command>.
          "help <command> <subcommand> prints help on <subcommand>.)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
byebug-3.5.1 lib/byebug/commands/help.rb
byebug-3.5.0 lib/byebug/commands/help.rb
byebug-3.4.2 lib/byebug/commands/help.rb
byebug-3.4.1 lib/byebug/commands/help.rb
byebug-3.4.0 lib/byebug/commands/help.rb
byebug-3.3.0 lib/byebug/commands/help.rb