up: ARG     index Zimbu documentation

CLASS ARG.String EXTENDS ARG.Flag @public

summary

     

A Flag that has one string argument.

For example, with this flag:

 ARG.String name = NEW("n", "name", "", "the name")
These arguments can be used:
 prog --name foobar
 prog --name=foobar
 prog -n foobar
 prog -nfoobar

By default the flag is not allowed to be used more than once. Use enableRepeat() to enable it.

NEW(shortName, longName, default, doc) @public  Create a String Flag.
$enableRepeat() ARG.String @public  Allow the flag to appear more than once.
$get() string @public  Return the value.
$value() string @public  Return the value.
$getList() list<string> @file  Return the list of values.
$valueList() list<string> @file  Return the list of values.
 
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, string default, string doc) @public

     

Create a String 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, used when the flag is not present. doc is displayed for this flag with the --help argument.

FUNC $enableRepeat() ARG.String @public

     

Allow the flag to appear more than once.

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

 ARG.String name = NEW("n", "name", "", "the name").enableRepeat()

The value of the last flag will then be stored and can be obtained with value(), getList() and valueList() return a list with all the values and presentCount() returns the number of times the flag appears.

This must be invoked in EarlyInit() or earlier.

FUNC $get() string @public

     

Return the value.

When the flag was not encountered it will be the specified default. Can only be used after EarlyInit(), when ARG.Ready is TRUE.

FUNC $getList() list<string> @file

     

Return the list of values.

When the flag was not encountered it will be an empty list Otherwise the list contains all the values encountered. When a flag doesn't have a value, the default value is used.

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

FUNC $value() string @public

     

Return the value.

When the flag was not encountered it will be the specified default. Can only be used after EarlyInit(), when ARG.Ready is TRUE.

FUNC $valueList() list<string> @file

     

Return the list of values.

When the flag was not encountered it will be an empty list Otherwise the list contains all the values encountered. When a flag doesn't have a value, the default value is used.

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