Long name for this option (--long_name on the command line)
Short name for this option (-short_name on the command line)
Default value for this option
Description of the parameter (used in help message)
Other flags that this option implicitly enables
Other flags that this option implicitly disables
Other options that are required to be set when using this options
Whether or not this option is exclusive and cannot be used with any other options (e.g. like --help where it prints the help message and exits)
Get the value
Get the value
This calls Option.get on the underlying value so an exception will be thrown if the value is not set.
Reset the value to the default
The value attached to this command line option (wrapped in an Option)
The value attached to this command line option (wrapped in an Option)
A boolean/flag command line option
Examples
import com.frugalmechanic.optparse._ object MyApp extends OptParse { // Basic flag using a default long name of --flag and short name of -f val flag = BoolOpt() // Example with all available options instead of relying on the defaults val verbose = BoolOpt( long="verbose", // Long name to use (--verbose) short="v", // Short name to use (-v) default=false, // Default value for this flag (true/false) desc="Be verbose", // Help message description enables=noisy, // Other flags to enable if this one is enabled (single option or a Seq of options) disables=Seq(quiet),// Other flags to disable if this one is enabled (single option or a Seq of options) invalidWith=quiet, // Other options this flag is invalid with (they cannot be set) validWith=noisy, // Other options that are required with this flag exclusive=false, // Other options can be set when this option is set ) // You can also use "new BoolOpt()" instead of using the companion object val noisy = new BoolOpt() val quiet = new BoolOpt() def main(args:Array[String]) { parse(args) if(verbose) println("You want verbose output") } }