Class: GLI::Commands::CompoundCommand

Inherits:
GLI::Command show all
Defined in:
lib/gli/commands/compound_command.rb

Overview

A command that calls other commands in order

Constant Summary

Constants inherited from GLI::Command

GLI::Command::PARENT

Instance Attribute Summary

Attributes included from GLI::CommandSupport

#parent

Attributes inherited from GLI::CommandLineToken

#aliases, #description, #long_description, #name

Instance Method Summary collapse

Methods inherited from GLI::Command

#action, #default_command, #default_desc, #example, #has_option?, name_as_string, #name_for_help

Methods included from GLI::CommandSupport

#arg_name, #arguments, #arguments_description, #arguments_options, #commands, #commands_declaration_order, #context_description, #default_description, #default_value, #desc, #examples, #flag, #flags, #get_default_command, #has_action?, #long_desc, #names, #nodoc, #skips_around, #skips_post, #skips_pre, #switch, #switches, #topmost_ancestor

Methods included from DSL

#arg, #arg_name, #clear_nexts, #command, #command_missing, #default_value, #desc, #flag, #flags_declaration_order, #long_desc, #switch, #switches_declaration_order

Methods inherited from GLI::CommandLineToken

#<=>, #names_and_aliases

Constructor Details

#initialize(base, configuration, options = {}) ⇒ CompoundCommand

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.



8
9
10
11
12
13
14
15
16
17
# 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

Instance Method Details

#execute(global_options, options, arguments) ⇒ Object

:nodoc:



19
20
21
22
23
# File 'lib/gli/commands/compound_command.rb', line 19

def execute(global_options,options,arguments) #:nodoc:
  @wrapped_commands.each do |command| 
    command.execute(global_options,options,arguments)
  end
end