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, #match

Methods included from StringFunctions

#camelize, #prettify

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject


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

def description
  prettify <<-EOD
    hist[ory] [num_cmds]        Show byebug's command history.
  EOD
end

.namesObject


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

def names
  %w(history)
end

Instance Method Details

#executeObject


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

def execute
  history = @state.interface.history

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

  puts history.to_s(size)
end

#regexpObject


8
9
10
# File 'lib/byebug/commands/history.rb', line 8

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