Class: Scatter::SuperCommand
- Defined in:
- lib/scatter/super_command.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(out, *args) ⇒ SuperCommand
constructor
A new instance of SuperCommand.
Methods inherited from Command
Constructor Details
#initialize(out, *args) ⇒ SuperCommand
Returns a new instance of SuperCommand.
12 13 14 15 16 |
# File 'lib/scatter/super_command.rb', line 12 def initialize(out, *args) super(out) @subcmd = args.shift @arguments = args end |
Class Method Details
Instance Method Details
#execute! ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/scatter/super_command.rb', line 18 def execute! subcmd_class = eval("#{self.class.name}::#{@subcmd.capitalize}") cmd = subcmd_class.new(@out, *@arguments) cmd.execute! rescue ArgumentError raise CommandLineError, "Wrong number of mandatory arguments for command #{self.class.command_name} #{@subcmd}" rescue NameError raise CommandLineError, "Unknown subcommand #{@subcmd} for command #{self.class.command_name}" end |