Class: Byebug::HistoryCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/history.rb

Overview

Show history of byebug commands.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



29
30
31
# File 'lib/byebug/commands/history.rb', line 29

def description
  %(hist[ory] [num_cmds]        Show byebug's command history.)
end

.namesObject



25
26
27
# File 'lib/byebug/commands/history.rb', line 25

def names
  %w(history)
end

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/byebug/commands/history.rb', line 10

def execute
  unless Setting[:autosave]
    return errmsg('Not currently saving history. ' \
                  "Enable it with \"set autosave\"")
  end

  if @match[:num_cmds]
    size, err = get_int(@match[:num_cmds], 'history', 1, Setting[:histsize])
    return errmsg(err) unless size
  end

  puts History.to_s(size || Setting[:histsize])
end

#regexpObject



6
7
8
# File 'lib/byebug/commands/history.rb', line 6

def regexp
  /^\s* hist(?:ory)? (?:\s+(?<num_cmds>.+))? \s*$/x
end