Sha256: b773f55c6bf2c0178a964c022723bab33c650befd8c5044744f29b87a3438069

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

module Byebug

  # Implements byebug "help" command.
  class HelpCommand < Command
    include Columnize

    self.allow_in_control = true

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

    def execute
      if @match[1]
        args = @match[1].split
        cmds = @state.commands.select { |cmd| cmd.names.include?(args[0]) }
        unless cmds.empty?
          help = cmds.map{ |cmd| cmd.help(args) }.join
          help = help.split("\n").map{|l| l.gsub(/^ +/, '')}
          help.shift if help.first && help.first.empty?
          help.pop if help.last && help.last.empty?
          return print help.join("\n") + "\n"
        else
          return errmsg "Undefined command: \"#{args[0]}\".  Try \"help\".\n" if
            args[0]
        end
      end

      print "byebug help v#{Byebug::VERSION}\n" unless
        Command.settings[:testing]

      print "Type \"help <command-name>\" for help on a specific command\n\n"
      print "Available commands:\n"
      cmds = @state.commands.map{ |cmd| cmd.names }.flatten.uniq.sort
      print columnize(cmds, Command.settings[:width])
    end

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

      def description
        %{
          h[elp]\t\tprint this help
          h[elp] command\tprint help on command
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
byebug-1.4.1 lib/byebug/commands/help.rb
byebug-1.4.0 lib/byebug/commands/help.rb
byebug-1.3.1 lib/byebug/commands/help.rb
byebug-1.3.0 lib/byebug/commands/help.rb
byebug-1.2.0 lib/byebug/commands/help.rb
byebug-1.1.1 lib/byebug/commands/help.rb