Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Gem::Command#add_option

add_option(*opts) { |value, options| ... }

Add a command-line option and handler to the command.

See Gem::OptionParser#make_switch for an explanation of opts.

handler will be called with two values, the value of the argument and the options hash.

If the first argument of add_option is a Symbol, it’s used to group options in output. See ‘gem help list` for an example.