Method: GitCommander::Command#add_option

Defined in:
lib/git_commander/command.rb

#add_option(option_type, options = {}) ⇒ Object

Add to this Command’s #arguments, #flags, or #switches

Parameters:

  • option_type (String, Symbol)

    the type of option to add

  • options (Hash) (defaults to: {})

    the options to create the [Option] with

Options Hash (options):

  • :name (String, Symbol)

    the name of the option to add

  • :default (Object) — default: nil

    the default value of the Option

  • :description (String) — default: nil

    a description of the Option to use in help text output

  • :value (Object) — default: nil

    the value on of the Option



97
98
99
100
101
102
103
104
105
106
# File 'lib/git_commander/command.rb', line 97

def add_option(option_type, options = {})
  case option_type.to_sym
  when :argument
    @arguments << Option.new(**options)
  when :flag
    @flags << Option.new(**options)
  when :switch
    @switches << Option.new(**options)
  end
end