module Thor::RichOptions::AtLeastOne

Public Instance Methods

at_least_one(*args, &block)
Alias for: method_at_least_one
method_at_least_one(*args, &block) click to toggle source

Adds and declareds option group for required at least one of options in the block of arguments. You can declare options as the outside of the block. If :for is given as option, it allows you to change the options from a prvious defined command.

Parameters

Array

options<Hash>

:for is applied for previous defined command.

Examples

at_least_one do
  option :one
  option :two
 end

Or

option :one
option :two
at_least_one :one, :two

If you do not give “–one” and “–two”. AtLeastOneRequiredArgumentError will be raised.

You can use at_least_one and exclusive at the same time.

exclusive do
  at_least_one do
    option :one
    option :two
  end
end

Then it is required either only one of “–one” or “–two”.

# File lib/thor/rich_options/at_least_one.rb, line 50
def method_at_least_one(*args, &block)
  register_options_relation_for(:method_options,
                                :method_at_least_one_option_names, *args, &block)
end
Also aliased as: at_least_one
method_at_least_one_option_names() click to toggle source

Returns this class at least one of required options array set.

Rturns

Array[Array]

# File lib/thor/rich_options/at_least_one.rb, line 10
def method_at_least_one_option_names
  @method_at_least_one_option_names ||=[]
end
print_at_least_one_required_options(shell, command = nil) click to toggle source