class Commando::Action::History

Action that prints out command history

Attributes

config[R]

Public Class Methods

new(config:) click to toggle source
# File lib/commando/action/history.rb, line 7
def initialize(config:)
  @config = config
end

Public Instance Methods

perform(args:) click to toggle source
# File lib/commando/action/history.rb, line 11
def perform(args:)
  max_digits = Math.log(Readline::HISTORY.size, 10).ceil
  Readline::HISTORY.each.with_index do |history, index|
    line_no = (index + 1).to_s.rjust(max_digits, ' ')
    config.output.puts " #{line_no}\t#{history}"
  end
end