Otherwise, here is a quick-reference.
- Four required flags (no ordering)
The simplest example, where we add four required flags, which have no ordering. - Four required flags (no ordering), accessing via the module name.
Exact same as the previous, except we show that the module name may be used to access the flag values, if you don't want to get them from ARGV. (It's a style thing) - Changing the universal short-form symbol
Everything is still the same, except we are now changing the default symbol from '-' to '/' - Adding an optional flag and a usage flag.
The optional flag allows us to declare that the flag is not required. Even though the help flag comes automatically with 'and_process!' we can add more synonymns for the default '-h' and '-?'. Also, we show how to use the flag with a ? method. - Using an extended usage flag
The extended usage flag allows us to ask for detailed information about our declared flags. - Adding 'description' as our first clause-level modifier.
Adding descriptions to the flags so that they will appear in extended help - Adding alternate forms and long forms
Alternate forms may be used in place of the regular flag. Long forms are used with the long form dispatch symbol (usually '--') - Other clause-level modifiers, like arity and flag symbol
Description for ../src/examples/example_2_4.rb - Help flag can be used for a specific flag.
The normal help flag can be used with a parameter so that you can get more information on any of the particular flags. - Using the optional switch flag, a zero argument optional flag
If your flag is optional and without arguments, it is a switch. Use optional_switch_flag to indicate. - Adding validation rules to the value of an input flag
See the flags "mode", "run_date", and "connection" for examples of both forcing values to be in a set (value_in_set) or to match a particular regexp (value_matches). - Accessing values of the flags through a hash instead of a method.
Usually we have been accessing by doing this 'ARGV.flags.dir' but if you have a flag with a non alpha-numeric flag can't be accessed via a method name. Therefore we have to use a hash. - Character flags and clustering.
character flags are simple single character flags with zero arity and which are optional. An optional symbol as a second parameter to the 'character_flag' groups the character within a cluster in the same name. This last point will probably change (see 'discussion' on the web page for a better idea). - SUPER EASY alternative method for getting command line options into your program.
Rather than use the 'module' DSL syntax, we just re-use an existing class. Any method accessor will be used verbatim as a switch. OptiFlag will crawl up the inheritance hierarchy up to (but not including) object and use all accessors as standard 'flag's.
