Awkl
Loading...
Searching...
No Matches
opt Namespace Reference

Functions

unassigned parser (array P, string name, string version, string description, prefix, long_prefix, auto_help, auto_version)
 Create command-line argument parser.
 
unassigned argument (array P, string name, string args, string help, number nargs, any default, any implicit, string action)
 Add option argument to parser.
 
unassigned flag (array P, string name, string args, string help, string action)
 Add boolean option (flag) to parser.
 
unassigned param (array P, string name, string args, string help, any default, string action)
 Add option with 1 argument to parser.
 
unassigned option (array P, string name, string args, string help, any default, any implicit, string action)
 Add option with optional argument to parser.
 
unassigned counter (array P, string name, string args, string help, any default, number inc)
 Add counter option to parser.
 
string generateSynopsis (array P, string|number color, number ind1n)
 Generate command synopsis usage message from a parser.
 
string generateHelp (array P, string|number color, number desc_margin, number ind1n)
 Generate help usage message from a parser.
 
auto showHelp (O, R, P)
 Action for showing help message.
 
auto showVersion (O, R, P)
 Action for showing version.
 
auto setDefaults (R, P)
 Set default values to a result array from a parser.
 
bool get (array O, array P, array< string > argv, number argc)
 Get results of analyzing the next option argument from a parser. Iterator function.
 
number parse (array P, array R, array< string > argv, number argc)
 Parse a result array from a parser and command-line arguments.
 
auto count (O, R, P)
 Action for counting number of times passed.
 

Function Documentation

◆ argument()

unassigned opt::argument ( array P,
string name,
string args,
string help,
number nargs,
any default,
any implicit,
string action )

Add option argument to parser.

Parameters
[in,out]PCommand-line argument parser
nameName of the option argument
argsBlank separated list of strings (e.g. -a --alpha) the option corresponds to
helpHelp message for the option
nargsNumber of arguments the option takes
defaultDefault value for the option: The value when it is not passed
implicitImplicit value for the option: The value when it is passed with no argument
actionFunction name of an action to take when parsing the option
Returns

◆ count()

auto opt::count ( O ,
R ,
P  )

Action for counting number of times passed.

◆ counter()

unassigned opt::counter ( array P,
string name,
string args,
string help,
any default,
number inc )

Add counter option to parser.

Parameters
[in,out]PCommand-line argument parser
nameName of the option argument
argsBlank separated list of strings (e.g. -a --alpha) the option corresponds to
helpHelp message for the option
defaultDefault value for the option: The value when it is not passed
incIncrementing step
Returns
Examples
opt_parse.awk.

◆ flag()

unassigned opt::flag ( array P,
string name,
string args,
string help,
string action )

Add boolean option (flag) to parser.

Parameters
[in,out]PCommand-line argument parser
nameName of the option argument
argsBlank separated list of strings (e.g. -a --alpha) the option corresponds to
helpHelp message for the option
actionFunction name of an action to take when parsing the option
Returns
Examples
opt_get.awk, and opt_parse.awk.

◆ generateHelp()

string opt::generateHelp ( array P,
string|number color,
number desc_margin,
number ind1n )

Generate help usage message from a parser.

Parameters
PCommand-line argument parser
colorColor to use. No color by default, cyan if 1
desc_marginNumber of spaces to separate help descriptions
ind1nNumber of spaces to indent with
Returns
Help message for the CLI program

◆ generateSynopsis()

string opt::generateSynopsis ( array P,
string|number color,
number ind1n )

Generate command synopsis usage message from a parser.

Parameters
PCommand-line argument parser
colorColor to use. No color by default, cyan if 1
ind1nNumber of spaces to indent with
Returns
Synopsis for the CLI program

◆ get()

bool opt::get ( array O,
array P,
array< string > argv,
number argc )

Get results of analyzing the next option argument from a parser. Iterator function.

Parameters
[out]ORunning results of option parsing with the following keys:
  • c: Name of the current option recognized or the nullbyte \0 is if it was not recognized
  • opt: Current string option
  • arg: Argument to the current string option
  • ind: Current index in argv
[in]PCommand-line argument parser
argvArray of CLI arguments to parse
argcNumber of CLI arguments to parse
Returns
true if positional parameters are still not reached. false otherwise
Examples
opt_get.awk.

◆ option()

unassigned opt::option ( array P,
string name,
string args,
string help,
any default,
any implicit,
string action )

Add option with optional argument to parser.

Parameters
[in,out]PCommand-line argument parser
nameName of the option argument
argsBlank separated list of strings (e.g. -a --alpha) the option corresponds to
helpHelp message for the option
defaultDefault value for the option: The value when it is not passed
implicitImplicit value for the option: The value when it is passed with no argument
actionFunction name of an action to take when parsing the option
Returns
Examples
opt_get.awk, and opt_parse.awk.

◆ param()

unassigned opt::param ( array P,
string name,
string args,
string help,
any default,
string action )

Add option with 1 argument to parser.

Parameters
[in,out]PCommand-line argument parser
nameName of the option argument
argsBlank separated list of strings (e.g. -a --alpha) the option corresponds to
helpHelp message for the option
defaultDefault value for the option: The value when it is not passed
actionFunction name of an action to take when parsing the option
Returns
Examples
opt_get.awk, and opt_parse.awk.

◆ parse()

number opt::parse ( array P,
array R,
array< string > argv,
number argc )

Parse a result array from a parser and command-line arguments.

Parameters
[out]PCommand-line argument parser
[out]RResult array whose keys are the parser's options' names, or _error if an unrecognized option was passed
argvArray of strings of the command-line arguments
argcOptional
Returns
Index in argv where positional parameters start
Examples
opt_parse.awk.

◆ parser()

unassigned opt::parser ( array P,
string name,
string version,
string description,
prefix ,
long_prefix ,
auto_help ,
auto_version  )

Create command-line argument parser.

Parameters
[out]PCommand-line argument parser
nameName of the CLI program
versionVersion of the CLI program
descriptionShort description of the CLI program
Returns
Examples
opt_get.awk, and opt_parse.awk.

◆ setDefaults()

auto opt::setDefaults ( R ,
P  )

Set default values to a result array from a parser.

◆ showHelp()

auto opt::showHelp ( O ,
R ,
P  )

Action for showing help message.

◆ showVersion()

auto opt::showVersion ( O ,
R ,
P  )

Action for showing version.