class GLI::Commands::CompoundCommand
A command that calls other commands in order
Public Class Methods
new(base,configuration,options={})
click to toggle source
- base
-
object that respondes to
commands
- configuration
-
Array of arrays: index 0 is the array of names of this command and index 1 is the names of the compound commands.
Calls superclass method
GLI::Command.new
# File lib/gli/commands/compound_command.rb, line 8 def initialize(base,configuration,options={}) name = configuration.keys.first super(options.merge(:names => [name])) command_names = configuration[name] check_for_unknown_commands!(base,command_names) @wrapped_commands = command_names.map { |name| self.class.find_command(base,name) } end
Private Class Methods
find_command(base,name)
click to toggle source
# File lib/gli/commands/compound_command.rb, line 36 def self.find_command(base,name) base.commands.values.find { |command| command.name == name } end
Private Instance Methods
check_for_unknown_commands!(base,command_names)
click to toggle source
# File lib/gli/commands/compound_command.rb, line 27 def check_for_unknown_commands!(base,command_names) known_commands = base.commands.keys.map(&:to_s) unknown_commands = command_names.map(&:to_s) - known_commands unless unknown_commands.empty? raise "Unknown commands #{unknown_commands.join(',')}" end end