Class: Scatter::SuperCommand
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
command_name, help, usage
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
.inherited(sub) ⇒ Object
7
8
9
|
# File 'lib/scatter/super_command.rb', line 7
def inherited(sub)
Command.inherited(sub)
end
|
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
|