Record TCmdArgs

Unit

Declaration

type TCmdArgs = record

Description

The command line parser.

Overview

Internal Types

TDoubleArray = specialize TArray<Double>;
TIntegerArray = specialize TArray<Integer>;

Methods

class operator initialize(var args : TCmdArgs);
class operator finalize(var args : TCmdArgs);
function ToString : String;
function flag(short : Char; desc : String; out opt : Boolean) : TOpt;
function flag(long : String; desc : String; out opt : Boolean) : TOpt;
function flag(short : Char; long : String; desc : String; out opt : Boolean) : TOpt;
function multi_flag(short : Char; desc : String; out count : Integer) : TOpt;
function multi_flag(long : String; desc : String; out count : Integer) : TOpt;
function multi_flag(short : Char; long : String; desc : String; out count : Integer) : TOpt;
function opt(short : Char; desc : String; out v : String) : TOpt;
function opt(long : String; desc : String; out v : String) : TOpt;
function opt(short : Char; long : String; desc : String; out v : String) : TOpt;
function opt(short : Char; desc : String; out v : TStringArray) : TOpt;
function opt(long : String; desc : String; out v : TStringArray) : TOpt;
function opt(short : Char; long : String; desc : String; out v : TStringArray) : TOpt;
function multi_opt(short : Char; desc : String; out v : TStringArray) : TOpt;
function multi_opt(long : String; desc : String; out v : TStringArray) : TOpt;
function multi_opt(short : Char; long : String; desc : String; out v : TStringArray) : TOpt;
function opt(short : Char; desc : String; out v : Integer) : TOpt;
function opt(long : String; desc : String; out v : Integer) : TOpt;
function opt(short : Char; long : String; desc : String; out v : Integer) : TOpt;
function opt(short : Char; desc : String; out v : TIntegerArray) : TOpt;
function opt(long : String; desc : String; out v : TIntegerArray) : TOpt;
function opt(short : Char; long : String; desc : String; out v : TIntegerArray) : TOpt;
function multi_opt(short : Char; desc : String; out v : TIntegerArray) : TOpt;
function multi_opt(long : String; desc : String; out v : TIntegerArray) : TOpt;
function multi_opt(short : Char; long : String; desc : String; out v : TIntegerArray) : TOpt;
function opt(short : Char; desc : String; out v : Double) : TOpt;
function opt(long : String; desc : String; out v : Double) : TOpt;
function opt(short : Char; long : String; desc : String; out v : Double) : TOpt;
function opt(short : Char; desc : String; out v : TDoubleArray) : TOpt;
function opt(long : String; desc : String; out v : TDoubleArray) : TOpt;
function opt(short : Char; long : String; desc : String; out v : TDoubleArray) : TOpt;
function multi_opt(short : Char; desc : String; out v : TDoubleArray) : TOpt;
function multi_opt(long : String; desc : String; out v : TDoubleArray) : TOpt;
function multi_opt(short : Char; long : String; desc : String; out v : TDoubleArray) : TOpt;
function param(paramname : String; desc : String; out v : String) : TOpt;
function param(paramname : String; desc : String; out v : Integer) : TOpt;
function param(paramname : String; desc : String; out v : Double) : TOpt;
function param(paramname : String; desc : String; out v : TStringArray) : TOpt;
function param(paramname : String; desc : String; out v : TIntegerArray) : TOpt;
function param(paramname : String; desc : String; out v : TDoubleArray) : TOpt;
procedure parse;
procedure parse(args: array of String);
procedure stopOnAll;
procedure stopOnLastParam;
procedure addHelp(short : Char = 'h'; long : String = 'help'; desc : String = 'Show this help page');

Properties

property programname : String read Fprogramname write Fprogramname;
property description : String read Fdescription write Fdescription;
property allowrest : Boolean read GetAllowRest write SetAllowRest;
property stopOn : String read FstopOn write FstopOn;
property additionalText : String read FadditionalText write FadditionalText;
property rest : TStringArray read Frest;

Description

Internal Types

TDoubleArray = specialize TArray<Double>;
 
TIntegerArray = specialize TArray<Integer>;
 

Methods

class operator initialize(var args : TCmdArgs);
 
class operator finalize(var args : TCmdArgs);
 
function ToString : String;

Return the help message

function flag(short : Char; desc : String; out opt : Boolean) : TOpt;

Add a flag with a short option.

A flag is a boolean option. If the flag is not specified, the variable `opt` is set to False and True otherwise.

Parameters
short
The single-dash short option character
desc
The description of this flag
opt
The variable containing the True iff the flag has been specified
Returns

TOpt The added option

function flag(long : String; desc : String; out opt : Boolean) : TOpt;

Add a flag with a long option.

A flag is a boolean option. If the flag is not specified, the variable `opt` is set to False and True otherwise.

Parameters
long
The double-dash long option name
desc
The description of this flag
opt
The variable containing the True iff the flag has been specified
Returns

TOpt The added option

function flag(short : Char; long : String; desc : String; out opt : Boolean) : TOpt;

Add a flag with a short and long option.

A flag is a boolean option. If the flag is not specified, the variable `opt` is set to False and True otherwise.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this flag
opt
The variable containing the True iff the flag has been specified
Returns

TOpt The added option

function multi_flag(short : Char; desc : String; out count : Integer) : TOpt;

Add a multi flag with a short option.

A flag is a boolean option. The variable `opt` is set to the number of times the flag has been specified.

Parameters
short
The single-dash short option character
desc
The description of this flag
opt
The variable containing the number of times the flag has been specified
Returns

TOpt The added option

function multi_flag(long : String; desc : String; out count : Integer) : TOpt;

Add a multi flag with a long option.

A flag is a boolean option. The variable `opt` is set to the number of times the flag has been specified.

Parameters
long
The double-dash long option name
desc
The description of this flag
opt
The variable containing the number of times the flag has been specified
Returns

TOpt The added option

function multi_flag(short : Char; long : String; desc : String; out count : Integer) : TOpt;

Add a multi flag with a short and long option.

A flag is a boolean option. The variable `opt` is set to the number of times the flag has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this flag
opt
The variable containing the number of times the flag has been specified
Returns

TOpt The added option

function opt(short : Char; desc : String; out v : String) : TOpt;

Add a string option with a short option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(long : String; desc : String; out v : String) : TOpt;

Add a string option with a long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; long : String; desc : String; out v : String) : TOpt;

Add a string option with a short and long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; desc : String; out v : TStringArray) : TOpt;

Add an option with a short option taking one or more string arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function opt(long : String; desc : String; out v : TStringArray) : TOpt;

Add an option with a long option taking on or more string arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function opt(short : Char; long : String; desc : String; out v : TStringArray) : TOpt;

Add an option with a short and long option taking on or more string arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function multi_opt(short : Char; desc : String; out v : TStringArray) : TOpt;

Add a string multi-option with a short option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function multi_opt(long : String; desc : String; out v : TStringArray) : TOpt;

Add a string multi-option with a long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function multi_opt(short : Char; long : String; desc : String; out v : TStringArray) : TOpt;

Add a string multi-option with a short and long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; desc : String; out v : Integer) : TOpt;

Add an integer option with a short option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(long : String; desc : String; out v : Integer) : TOpt;

Add an integer option with a long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; long : String; desc : String; out v : Integer) : TOpt;

Add an integer option with a short and long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; desc : String; out v : TIntegerArray) : TOpt;

Add an option with a short option taking one or more integer arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function opt(long : String; desc : String; out v : TIntegerArray) : TOpt;

Add an option with a long option taking on or more integer arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function opt(short : Char; long : String; desc : String; out v : TIntegerArray) : TOpt;

Add an option with a short and long option taking on or more integer arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function multi_opt(short : Char; desc : String; out v : TIntegerArray) : TOpt;

Add a integer multi-option with a short option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function multi_opt(long : String; desc : String; out v : TIntegerArray) : TOpt;

Add a integer multi-option with a long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function multi_opt(short : Char; long : String; desc : String; out v : TIntegerArray) : TOpt;

Add a integer multi-option with a short and long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; desc : String; out v : Double) : TOpt;

Add an double option with a short option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(long : String; desc : String; out v : Double) : TOpt;

Add an double option with a long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; long : String; desc : String; out v : Double) : TOpt;

Add an double option with a short and long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function opt(short : Char; desc : String; out v : TDoubleArray) : TOpt;

Add an option with a short option taking one or more double arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function opt(long : String; desc : String; out v : TDoubleArray) : TOpt;

Add an option with a long option taking on or more double arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function opt(short : Char; long : String; desc : String; out v : TDoubleArray) : TOpt;

Add an option with a short and long option taking on or more double arguments.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing the parameter values
Returns

TOpt The added option

function multi_opt(short : Char; desc : String; out v : TDoubleArray) : TOpt;

Add a double multi-option with a short option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function multi_opt(long : String; desc : String; out v : TDoubleArray) : TOpt;

Add a double multi-option with a long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function multi_opt(short : Char; long : String; desc : String; out v : TDoubleArray) : TOpt;

Add a double multi-option with a short and long option.

The variable `v` is the to the parameter value if it has been specified.

Parameters
short
The single-dash short option character
long
The double-dash long option name
desc
The description of this option
v
The variable containing parameter value
Returns

TOpt The added option

function param(paramname : String; desc : String; out v : String) : TOpt;
 
function param(paramname : String; desc : String; out v : Integer) : TOpt;
 
function param(paramname : String; desc : String; out v : Double) : TOpt;
 
function param(paramname : String; desc : String; out v : TStringArray) : TOpt;
 
function param(paramname : String; desc : String; out v : TIntegerArray) : TOpt;
 
function param(paramname : String; desc : String; out v : TDoubleArray) : TOpt;
 
procedure parse;

Parse the current programs command line arguments.

procedure parse(args: array of String);

Parse the specified list of command line arguments.

procedure stopOnAll;

Stop on each unknown parameter.

By default unknown parameters are skipped. If `stop_on_all` has been called, upon observing the first unknown parameter, the parser stops and adds all remaining parameters to `rest` immediately.

procedure stopOnLastParam;

Stop when the last parameter has been parsed.

All remaining parameters are added to `rest` immediately.

procedure addHelp(short : Char = 'h'; long : String = 'help'; desc : String = 'Show this help page');

Add a help option.

Adds an automatic -h, –help option. If this option is specified, a EHelp exception is raised.

Properties

property programname : String read Fprogramname write Fprogramname;

Set the program name.

property description : String read Fdescription write Fdescription;

Set the description of the command.

property allowrest : Boolean read GetAllowRest write SetAllowRest;

Allow rest parameters.

Additional command line arguments will cause an error.

The default is `true`.

property stopOn : String read FstopOn write FstopOn;

Set the stop separator.

If the stop separator is observed, the parser stops and all remaining parameters (excluding the separator) are added to `rest` immediately.

By default the separator is '–'.

property additionalText : String read FadditionalText write FadditionalText;

This text is shown at the end of the usage message.

property rest : TStringArray read Frest;

The unparsed parameters.


Generated by PasDoc 0.15.0.