Method: Bundler::Thor.method_option

Defined in:
lib/bundler/vendor/thor/lib/thor.rb

.method_option(name, options = {}) ⇒ Object Also known as: option

Adds an option to the set of method options. If :for is given as option, it allows you to change the options from a previous defined command.

def previous_command
  # magic
end

method_option :foo, :for => :previous_command

def next_command
  # magic
end

Parameters

name<Symbol>

The name of the argument.

options<Hash>

Described below.

Options

:desc - Description for the argument. :required - If the argument is required or not. :default - Default value for this argument. It cannot be required and have default values. :aliases - Aliases for this option. :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean. :banner - String to show on usage notes. :hide - If you want to hide this option from the help.

[View source]

163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/bundler/vendor/thor/lib/thor.rb', line 163

def method_option(name, options = {})
  unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }
    raise ArgumentError, "Expected a Symbol or String, got #{name.inspect}"
  end
  scope = if options[:for]
    find_and_refresh_command(options[:for]).options
  else
    method_options
  end

  build_option(name, options, scope)
end