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



715
716
717
718
719
720
721
722
723
724
725
726
# File 'lib/commands.rb', line 715

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