GetoptOptions type
The GetoptOptions structured array type that holds the definition of command line options.
Syntax
PUBLIC TYPE GetoptOptions DYNAMIC ARRAY OF RECORD
name STRING,
description STRING,
opt_char CHAR,
arg_type INTEGER
END RECORD
name
defines the long name of the command line option.description
is the text to explain the command line option.opt_char
is the single-char command line option name.arg_type
can be one of:getopt.NONE
: The option has no additional value argument.getopt.OPTIONAL
: The option can be used with an optional value argument (--option[=value]
).getopt.REQUIRED
: The option needs a mandatory value argument (--option=value
).
Usage
This type defines a dynamic array of a record structure to hold command line options definitions information.
Define a variable of the getopt.GetoptOptions
type and fill it with an initializer.
Once the array is initialized, it can be passed to the initDefault()
or
initialize()
method, to setup a Getopt
variable in order to process command line arguments with the getopt()
method.
Example
IMPORT FGL getopt
MAIN
DEFINE g getopt.Getopt
DEFINE _options getopt.GetoptOptions
= [(name: "version",
description: "Version information",
opt_char: 'v',
arg_type: getopt.NONE),
(name: "help",
description: "This help page",
opt_char: 'h',
arg_type: getopt.NONE),
(name: "outfile",
description: "Output filename",
opt_char: 'o',
arg_type: getopt.REQUIRED)]
CALL g.initDefault(_options)
...
END MAIN