Class: Commando::Action::History
- Inherits:
-
Object
- Object
- Commando::Action::History
- Defined in:
- lib/commando/action/history.rb
Overview
Action that prints out command history
Instance Method Summary collapse
-
#initialize(config:) ⇒ History
constructor
A new instance of History.
- #perform(args:) ⇒ Object
Constructor Details
#initialize(config:) ⇒ History
Returns a new instance of History.
7 8 9 |
# File 'lib/commando/action/history.rb', line 7 def initialize(config:) @config = config end |
Instance Method Details
#perform(args:) ⇒ Object
11 12 13 14 15 16 17 |
# 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 |