Class TOptionParser
Unit
Declaration
type TOptionParser = class(TObject)
Description
OptionParser — instantiate one of these for commandline parsing
This class is the main parsing class, although a lot of parsing is handled by TOption and its descendants instead.
Hierarchy
- TObject
- TOptionParser
Overview
Fields
FParams: TStringList; |
|
FOptions: TList; |
|
FLeftList: TStringList; |
|
FShortOptionChar: Char; |
|
FLongOptionString: string; |
|
FIncludeFileOptionName: string; |
|
FIncludeFileOptionExpl: string; |
Methods
function GetOption(const AIndex: Integer): TOption; |
|
function GetOptionsCount: Integer; |
|
function GetOptionByLongName(const AName: string): TOption; |
|
function GetOptionByShortname(const AName: char): TOption; |
|
constructor Create; virtual; |
|
constructor CreateParams(const AParams: TStrings); virtual; |
|
destructor Destroy; override; |
|
function AddOption(const AOption: TOption): TOption; |
|
procedure ParseOptions; |
|
procedure WriteExplanations; |
Properties
property LeftList: TStringList read FLeftList; |
|
property OptionsCount: Integer read GetOptionsCount; |
|
property Options[constAIndex:Integer]: TOption read GetOption; |
|
property ByName[constAName:string]: TOption read GetOptionByLongName; |
|
property ByShortName[constAName:char]: TOption read GetOptionByShortname; |
|
property ShortOptionStart: Char read FShortOptionChar write FShortOptionChar default DefShortOptionChar; |
|
property LongOptionStart: String read FLongOptionString write FLongOptionString; |
|
property IncludeFileOptionName: string read FIncludeFileOptionName write FIncludeFileOptionName; |
|
property IncludeFileOptionExpl: string read FIncludeFileOptionExpl write FIncludeFileOptionExpl; |
Description
Fields
FParams: TStringList; |
|
FOptions: TList; |
|
FLeftList: TStringList; |
|
FShortOptionChar: Char; |
|
FLongOptionString: string; |
|
FIncludeFileOptionName: string; |
|
FIncludeFileOptionExpl: string; |
|
Methods
function GetOption(const AIndex: Integer): TOption; |
|
function GetOptionsCount: Integer; |
|
function GetOptionByLongName(const AName: string): TOption; |
|
function GetOptionByShortname(const AName: char): TOption; |
|
constructor Create; virtual; |
|
Create without any options — this will parse the current command line |
constructor CreateParams(const AParams: TStrings); virtual; |
|
Create with parameters to be used instead of command line |
destructor Destroy; override; |
|
destroy the option parser object and all associated TOption objects |
function AddOption(const AOption: TOption): TOption; |
|
Add a TOption descendant to be included in parsing the command line |
procedure ParseOptions; |
|
Parse the specified command line, see also Create |
procedure WriteExplanations; |
|
output explanations for all options to stdout, will nicely format the output and wrap explanations |
Properties
property LeftList: TStringList read FLeftList; |
|
This StringList contains all the items from the command line that could not be parsed. Includes options that didn't accept their value and non-options like filenames specified on the command line |
property OptionsCount: Integer read GetOptionsCount; |
|
The number of option objects that were added to this parser |
property Options[constAIndex:Integer]: TOption read GetOption; |
|
retrieve an option by index — you can use this and OptionsCount to iterate through the options that this parser owns |
property ByName[constAName:string]: TOption read GetOptionByLongName; |
|
retrieve an option by its long form. Case sensitivity of the options is taken into account! |
property ByShortName[constAName:char]: TOption read GetOptionByShortname; |
|
retrieve an option by its short form. Case sensitivity of the options is taken into account! |
property ShortOptionStart: Char read FShortOptionChar write FShortOptionChar default DefShortOptionChar; |
|
introductory character to be used for short options |
property LongOptionStart: String read FLongOptionString write FLongOptionString; |
|
introductory string to be used for long options |
property IncludeFileOptionName: string read FIncludeFileOptionName write FIncludeFileOptionName; |
|
name of an option to include config file |
property IncludeFileOptionExpl: string read FIncludeFileOptionExpl write FIncludeFileOptionExpl; |
|
explanation of an option to include config file |
Generated by PasDoc 0.16.0.