Module OptiFlag::Flagset::NewInterface
In: ../src/optiflag.rb

The NewInterface module is used to augment the ARGV constant with some special methods that it never used to have before.

This is one of two hallmark ideas in making the OptiFlag suite easier to use:

  • easy declarative DSL syntax (all the flag set and flag declarations)
  • and this, an easy to use interface for accessing the results after the processor has finished processing.

To emphasize this point, consider the following declaration:

    module AppArgs extend OptiFlagSet
      flag "dir"
      optional_flag "log"
      flag "username"
      flag "password"


Note the special command ‘and_process!’ This method, which should, by rote, be placed at the end of the DSL-zone (the code internal to the module block) is augmenting the ARGV constant so that the results of the parsing are now available. Thus:


has a value of whatever the user passed in on the command line for the ’-dir’ flag. And


tells us whether the user supplied the log flag and if she did, we can access it using


Better looking code would be:

   log_file = ARGV.flag_value.log if ARGV.flag_value.log?


External Aliases

flag_value -> flags


errors  [RW] 
extended_help_requested  [W] 
flag_value  [RW] 
help_requested  [W] 
help_requested_on  [RW] 
specification_errors  [RW] 
warnings  [RW] 

Public Instance methods