lib/commando/action/help.rb in tcollier-commando-1.0.0 vs lib/commando/action/help.rb in tcollier-commando-2.0.0
- old
+ new
@@ -1,16 +1,24 @@
require_relative '../../commando'
module Commando
module Action
# Action that prints out all available commands
- module Help
- def self.perform(args:, output: $stdout)
- output.puts "Valid commands are"
- descriptions = Commando.config.descriptions
+ class Help
+ def initialize(config:)
+ @config = config
+ end
+
+ def perform(args:)
+ config.output.puts "Valid commands are"
+ descriptions = config.descriptions
descriptions.sort_by { |cmd, _| cmd }.each do |command, description|
- output.puts " * #{command} - #{description}"
+ config.output.puts " * #{command} - #{description}"
end
end
+
+ private
+
+ attr_reader :config
end
end
end