lib/commando/action/history.rb in tcollier-commando-1.0.0 vs lib/commando/action/history.rb in tcollier-commando-2.0.0
- old
+ new
@@ -1,16 +1,24 @@
require 'readline'
module Commando
module Action
# Action that prints out command history
- module History
- def self.perform(args:, output: $stdout)
+ class History
+ def initialize(config:)
+ @config = config
+ end
+
+ 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, ' ')
- output.puts " #{line_no}\t#{history}"
+ config.output.puts " #{line_no}\t#{history}"
end
end
+
+ private
+
+ attr_reader :config
end
end
end