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.



1270
1271
1272
1273
# File 'lib/commands.rb', line 1270

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

Instance Method Details

#attach(commands) ⇒ Object



1275
1276
1277
1278
1279
1280
1281
1282
1283
# File 'lib/commands.rb', line 1275

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