lib/commando/config.rb in tcollier-commando-0.1.0 vs lib/commando/config.rb in tcollier-commando-0.1.1
- old
+ new
@@ -2,10 +2,11 @@
require_relative 'action/history'
require_relative 'action/quit'
module Commando
ActionConfig = Struct.new(:action_class, :description)
+ private_constant :ActionConfig
# Manage the configuration for the actions available to the CLI
class Config
DEFAULT_PROMPT = 'commando> '
DEFAULT_GREETING =
@@ -50,14 +51,13 @@
# nil if none is registered.
def lookup(command)
mapping[command]&.action_class
end
- # Iterate through each of the registered commands, yielding the command
- # string and the description
- def each_action(&block)
- mapping.each do |command, action_config|
- yield command, action_config.description
+ # @return [Hash<String, String>] a map of commands to their descriptions
+ def descriptions
+ mapping.map.with_object({}) do |(command, action_config), hash|
+ hash[command] = action_config.description
end
end
private