Class: Commands::GlobalOption

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

Methods inherited from CommandOption

#initialize

Constructor Details

This class inherits a constructor from Commands::CommandOption

Instance Method Details

#attach(commands) ⇒ Object



692
693
694
695
696
697
698
699
700
701
702
703
# File 'lib/commands.rb', line 692

def attach(commands)
  global_options = @commands.global_options
  value = global_options[@field_symbol]
  if value.is_a?(Array) then
    value << @arg
  elsif value == nil then
    global_options[@field_symbol] = @arg
  else
    raise RuntimeError, "You may not specify #{@name} twice"
  end
  return nil
end