Commander::Command#option

Parsed documentation:
View on GitHub
Add an option.

Options are parsed via OptionParser so view it
for additional usage documentation. A block may optionally be
passed to handle the option, otherwise the _options_ struct seen below
contains the results of this option. This handles common formats such as:

  -h, --help          options.help           # => bool
  --[no-]feature      options.feature        # => bool
  --large-switch      options.large_switch   # => bool
  --file FILE         options.file           # => file passed
  --list WORDS        options.list           # => array
  --date [DATE]       options.date           # => date or nil when optional argument not set

=== Examples

  command :something do |c|
    c.option '--recursive', 'Do something recursively'
    c.option '--file FILE', 'Specify a file'
    c.option('--info', 'Display info') { puts "handle with block" }
    c.option '--[no-]feature', 'With or without feature'
    c.option '--list FILES', Array, 'List the files specified'

    c.when_called do |args, options|
      do_something_recursively if options.recursive
      do_something_with_file options.file if options.file
    end
  end

=== Help Formatters

This method also parses the arguments passed in order to determine
which were switches, and which were descriptions for the
option which can later be used within help formatters
using option[:switches] and option[:description].

=== Input Parsing

Since Commander utilizes OptionParser you can pre-parse and evaluate
option arguments. Simply require 'optparse/time', or 'optparse/date', as these
objects must respond to #parse.

  c.option '--time TIME', Time
  c.option '--date [DATE]', Date
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.