up: ARG     index Zimbu documentation

CLASS ARG.Bool EXTENDS ARG.Flag @public

summary

     

A Flag that has no argument, it's presence is noted.

For example, with this flag:

 ARG.Bool verbose = NEW("v", "verbose", FALSE, "verbose messages")
These arguments can be used:
 prog --verbose
 prog --noverbose
 prog -v
 prog -vvv
 prog --verbose=yes

When the flag is present the value becomes the inversion of the default value.

The value can be set to TRUE with "--verbose=yes" and "--verbose=true".

The value can be set to FALSE with "--verbose=no" and "--verbose=false" and "--noverbose".

"--noverbose" only works as "--verbose=no" when there is no flag called "noverbose".

By default the flag is allowed to be used more than once, use presentCount() to obtain the number of times. Use disableRepeat() to disable this.

Using the argument:

 IF verbose.get()
   IO.print("verbose output")
   IF verbose.presentCount() >= 3
     IO.print("VERY verbose")
   }
 }

NEW(shortName, longName, default, doc) @public  Create a Bool Flag.
$disableRepeat() ARG.Bool @public  Disable repeating the flag.
$get() bool @public  Return the value.
$value() bool @public  Return the value.
 
Inherited from ARG.Flag:
$setArgName(argName) ARG.Flag @public  Set the text used in the --help output for the argument.
$disableCompact() ARG.Flag @public  Disable the compact form of flag values.
$optionalArg() ARG.Flag @public  Make the flag argument optional.
$presentCount() int @public  Return the number of times the command line flag was encountered.
$present() bool @public  Return TRUE if the command line flag was encountered.
 

members (alphabetically)

     

PROC NEW(string shortName, string longName, bool default, string doc) @public

     

Create a Bool Flag.

shortName is the one-character name, can be NIL. longName is the longer name, to be used after "--", can be NIL shortName and longName can't both be NIL. default is the default value. When the flag is encountered the opposite of this value will become the current value. doc is displayed for this flag with the --help argument.

FUNC $disableRepeat() ARG.Bool @public

     

Disable repeating the flag.

Returns the Flag, so that it can be used in a declaration like this:

 ARG.Bool  = NEW("v", "verbose", FALSE, "verbose messages").disableRepeat()

This must be invoked in EarlyInit() or earlier.

FUNC $get() bool @public

     

Return the value.

When the flag was not encountered it will be the specified default, otherwise the opposite.

Can only be used after EarlyInit(), when ARG.Ready is TRUE.

FUNC $value() bool @public

     

Return the value.

When the flag was not encountered it will be the specified default, otherwise the opposite.

Can only be used after EarlyInit(), when ARG.Ready is TRUE.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0