Class: Commands::ParamOption

Inherits:
CommandOption show all
Defined in:
lib/commands.rb

Instance Attribute Summary

Attributes inherited from CommandOption

#arg, #commands, #description, #name, #parent_commands

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ParamOption

Returns a new instance of ParamOption.



1314
1315
1316
1317
# File 'lib/commands.rb', line 1314

def initialize(*args)
  super(*args)
  @params = []
end

Instance Method Details

#attach(commands) ⇒ Object



1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'lib/commands.rb', line 1319

def attach(commands)
  command = super(commands)
  if match = @arg.match(/([^=]+)=(.*)/) then
    command.option(@name, @field_symbol, { :key => match[1], :value => match[2] })
  else
    raise RuntimeError, "Expected '#{@arg}' to be in the form VARIABLE=VALUE"
  end
  return command
end