Unit CastleParameters

Description

Processing command-line parameters and options (TParameters, single instance Parameters).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class EInvalidParams  
Class EInvalidShortOption  
Class EInvalidLongOption  
Class EWrongOptionArgument  
Class EExcessiveOptionArgument  
Class EMissingOptionArgument  
Record TOption Command-line option specification, for TParameters.Parse.
Class TParameters Storing and processing command-line parameters and options.

Functions and Procedures

function SeparateArgsToVector3(const v: TSeparateArgs): TVector3;
function SeparateArgsToVector3Single(const v: TSeparateArgs): TVector3; deprecated 'use SeparateArgsToVector3';
function OptionDescription(const Name, Description: string): string;

Types

TOptionArgument = (...);
TOptionArguments = set of TOptionArgument;
TOptionSeparateArgument = oaRequiredSeparateFirst .. oaRequiredSeparateLast;
TSeparateArgs = array[1..RequiredSeparateLastCount] of string;
TOptionProc = procedure (OptionNum: Integer; HasArgument: boolean; const Argument: string; const SeparateArgs: TSeparateArgs; Data: Pointer);
POption = ˆTOption;
TOption_Array = array [0..MaxInt div SizeOf(TOption) - 1] of TOption;
POption_Array = ˆTOption_Array;

Constants

oaRequiredSeparateFirst = oaRequired2Separate;
oaRequiredSeparateLast = oaRequired9Separate;
RequiredSeparateFirstCount = 2;
RequiredSeparateLastCount = RequiredSeparateFirstCount + Ord(oaRequiredSeparateLast) - Ord(oaRequiredSeparateFirst);
OptionArgumentsRequiredSeparate: TOptionArguments = [oaRequiredSeparateFirst .. oaRequiredSeparateLast];
EmptySeparateArgs: TSeparateArgs = ('','','', '','','', '','','');
OnlyHelpOptions: array [0..0] of TOption = ( (Short: 'h'; Long: 'help'; Argument: oaNone) ) deprecated 'define this in your application';
HelpOptionHelp = ' -h / --help Print this help message and exit.' deprecated 'use OptionDescription';
VersionOptionHelp = ' -v / --version Print the version number and exit.' deprecated 'use OptionDescription';

Variables

Parameters: TParameters;

Description

Functions and Procedures

function SeparateArgsToVector3(const v: TSeparateArgs): TVector3;

This item has no description.

function SeparateArgsToVector3Single(const v: TSeparateArgs): TVector3; deprecated 'use SeparateArgsToVector3';

Warning: this symbol is deprecated: use SeparateArgsToVector3

This item has no description.

function OptionDescription(const Name, Description: string): string;

Return a multiline command-line option help, containing the option name and description, nicely indented and broken into multiple lines. Existing newlines in Description are correctly accounted for.

Types

TOptionArgument = (...);

This item has no description.

Values
  • oaNone: No arguments allowed.
  • oaOptional: An optional argument. It must be given as --option=argument or (short form) -o=argument.

    If you use a short form and you combine many short option names into one parameter, then only the last option may have an argument. For example -abc=blah is equivalent to -a -b -c=blah.

  • oaRequired: A required argument. It must be given as for oaOptional, but this time the equal sign is not needed (we know anyway that following parameter must be an argument). So the following versions are possible:

    --option=argument # long form, as one parameter
    --option argument # long form, as two parameters
    -o=argument # short form, as one parameter
    -o argument # short form, as two parameters

  • oaRequired2Separate: We require a specified (more than one) argument. All of the arguments must be specified as separate parameters, like

    --option Argument1 Argument2
    -o Argument1 Argument2

  • oaRequired3Separate
  • oaRequired4Separate
  • oaRequired5Separate
  • oaRequired6Separate
  • oaRequired7Separate
  • oaRequired8Separate
  • oaRequired9Separate
TOptionArguments = set of TOptionArgument;

This item has no description.

TOptionSeparateArgument = oaRequiredSeparateFirst .. oaRequiredSeparateLast;

This item has no description.

TSeparateArgs = array[1..RequiredSeparateLastCount] of string;

This item has no description.

TOptionProc = procedure (OptionNum: Integer; HasArgument: boolean; const Argument: string; const SeparateArgs: TSeparateArgs; Data: Pointer);

Callback used by TParameters.Parse to notify about new option.

Parameters
OptionNum
The option number in the Options table (zero-based).
HasArgument
Says if you have a single argument in the Argument parameter. Always False when your option has oaNone or oaRequiredXSeparate. Always True when your option has oaRequired. For oaOptional, this is how you know if the optional argument was used.
Argument
A single argument for oaRequired or oaOptional, only if HasArgument. Otherwise empty string.
SeparateArgs
For options using oaRequiredXSeparate, your arguments are here. You get exactly as many argument as your oaRequiredXSeparate requested, the rest of SeparateArgs is empty strings.
Data
This is the OptionProcData value you passed to TParameters.Parse, use this to pass some pointer to your callback.
POption = ˆTOption;

This item has no description.

TOption_Array = array [0..MaxInt div SizeOf(TOption) - 1] of TOption;

This item has no description.

POption_Array = ˆTOption_Array;

This item has no description.

Constants

oaRequiredSeparateFirst = oaRequired2Separate;

This item has no description.

oaRequiredSeparateLast = oaRequired9Separate;

This item has no description.

RequiredSeparateFirstCount = 2;

This item has no description.

RequiredSeparateLastCount = RequiredSeparateFirstCount + Ord(oaRequiredSeparateLast) - Ord(oaRequiredSeparateFirst);

This item has no description.

OptionArgumentsRequiredSeparate: TOptionArguments = [oaRequiredSeparateFirst .. oaRequiredSeparateLast];

This item has no description.

EmptySeparateArgs: TSeparateArgs = ('','','', '','','', '','','');

This item has no description.

OnlyHelpOptions: array [0..0] of TOption = ( (Short: 'h'; Long: 'help'; Argument: oaNone) ) deprecated 'define this in your application';

Warning: this symbol is deprecated: define this in your application

This item has no description.

HelpOptionHelp = ' -h / --help Print this help message and exit.' deprecated 'use OptionDescription';

Warning: this symbol is deprecated: use OptionDescription

This item has no description.

VersionOptionHelp = ' -v / --version Print the version number and exit.' deprecated 'use OptionDescription';

Warning: this symbol is deprecated: use OptionDescription

This item has no description.

Variables

Parameters: TParameters;

Command-line parameters. Initialized from standard ParamStr(0) ... ParamStr(ParamCount). Can be later modified, which is good — you can remove handled parameters. You also have all the methods of TCastleStringList class (e.g. you can assign to another TCastleStringList instance).


Generated by PasDoc 0.16.0-snapshot.