linearc.ppIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers Classes hierarchy graph
|
Class ACommandLineOption
Unit
linearc
Declaration
type ACommandLineOption = class(ADictionaryEntry)
Description
no description available, ADictionaryEntry description follows Hierarchy
Overview
Fields
Methods
Description
Fields
|
myDefaultValue: Variant; |
Stores the default value of the option
|
|
myRequirement: boolean; |
Indicates whether the option is required
|
|
myDirtiness: boolean; |
Indicates whether the option has been set by the user
|
|
myValueDescription: string; |
Stores a description of the type of value expected by the option
|
|
myDescription: string; |
Stores a description of the option
|
|
myOptionDirtiedHandler: AnOptionDirtiedHandler; |
Stores a callback which is invoked if the option has been dirtied (set)
|
Methods
|
constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const thisDescription: string; const thisValueDescription: string = ''; const onOptionDirtied: AnOptionDirtiedHandler = nil); reintroduce; virtual; |
Construct a new command-line option with the specified name.
This method constructs a new instance of ACommandLineOption with the specified defaultValue . The caller can also set whether the option is required and can provide a description of the option which will be used when the user requests help.
.
Parameters
- thisName
- specifies the name of the option as it should be supplied on the command-line. It is case-sensitive.
- isRequired
- indicates whether or not the user MUST supply the option on the command line.
- isRest
- indicates whether or not the option is a rest argument; if
True , then the user need not supply the name of the argument on the command line
- thisDefaultValue
- is used to set the initial value of the option.
- thisDescription
- is used to describe the purpose of the option to the user.
- thisValueDescription
- is used to describe the type of value accepted by the option. If this parameter is left blank, a default description is used, depending on the type of option represented by the new instance.
|
|
function init: boolean; override; |
Initializer
|
|
destructor destroy; override; |
Destroy the option.
This method overrides the behavior inherited from ANode.destroy; it does not attempt to destroy any children of the node. Since any such children represent abbreviated forms of the option, and so are entered into the main dictionary of options, they will be freed along with all other top-level options.
This method still causes the destruction of all older siblings of the node by recursively traversing ACommandLineOption.Previous and freeing each node encountered until a Nil result is found. If this behavior is not desired, then the node should be detached from its siblings by calling ACommandLineOption.detach before this node is freed.
Otherwise, TObject.free can be called on the last option in a list of options and it will cause the destruction of the entire list.
|
|
function Abbreviations: AStringList; virtual; |
Obtain the names of any abbreviations specified for the option.
If an option has an abbreviated form, this abbreviation may be specified on the command line instead of the full name of the option.
Abbreviations are specified at the time the option is entered into an instance of ACommandLineOptionDictionary. This method checks to see whether ACommandLineOption.Child has been set to a value that is not Nil ; if so, it traverses the list of children, querying the name of each one. These are inserted into a string list which is subsequently returned to the caller.
Returns
An instance of AStringList that contains the names of all abbreviations specified for the option. The caller is responsible for freeing this list when it is no longer required. If the option has no abbreviations, this method returns Nil . |
|
function usageString: AnsiString; virtual; |
Construct and return a string representation that describes the name, accepted values, and usage of the option. This0 method is designed to provide assistance to the user when they request help from the command line.
|
|
function shallowCopyFrom(const Other: AnObject): boolean; override; |
Construct a shallow copy of the other object.
This method overrides the behavior inherited from ASymbol.shallowCopyFrom: it calls that routine first, then checks to see whether Other is an instance of ACommandLineOption. If so, it copies the values of ACommandLineOption.required, ACommandLineOption.dirty and ACommandLineOption.description from Other to Self , overwriting the corresponding values in Self .
Note that this method does NOT copy any sibling or child nodes and so cannot be used to create a full copy of any descendant of ANode. Likewise, it does NOT copy the left or right subtrees and so cannot be used to create a full copy of any descendant of ABinaryLeaf.
|
|
function defaultValue: Variant; virtual; |
Retrieve the default value of the option. This is set when the option is constructed and cannot be changed.
|
|
function setValue(const newValue: Variant; const makeDirty: boolean = true): Variant; reintroduce; virtual; |
Set the current value of the option.
If makeDirty is False , then calling this method will not change the dirty flag that indicates the change has been made by the user.
Returns
The previous value of ACommandLineOption.value. |
|
function optionType: AnOptionValueType; virtual; |
Retrieve the option type. This is set by the option when it is constructed and cannot be changed.
|
|
function required: boolean; virtual; |
Retrieve whether or not the option is required: whether it must be specified on the command-line by the user.
If this routine returns True , then an error will be returned to the user if ACommandLineOption.dirty returns False , since that indicates the option is required but was not set by the user.
|
|
function setRequired(const flag: boolean): boolean; virtual; |
Set whether or not the option is required: whether it must be specified on the command-line by the user.
If an option is required but ACommandLineOption.dirty returns False , then an error will be returned to the user, since that indicates that the option is required but was not set by the user.
Returns
The previous value of ACommandLineOption.required. |
|
function isRestArgument: boolean; virtual; |
Determine whether or not the option is a rest argument; that is, an option that does not require its name to be provided on the command line.
This method simply checks to see whether ovtRest is in the set of values defined by ACommandLineOption.optionType.
|
|
function dirty: boolean; virtual; |
Retrieve whether or not the option has been set by the user.
If this routine returns True , then the option was found on the command line and its value set from there; otherwise, the option still retains its default value or a value that was not set by the user.
If this method returns False , but ACommandLineOption.required is True , then an error will be returned to the user, since that indicates that the option is required but was not set by the user.
|
|
function setDirty(const flag: boolean): boolean; virtual; |
Set whether or not the option is dirty.
If flag is True , then it indicates that the option and its value were found while parsing the command line – the option has been set by the user.
Returns
The previous value of ACommandLineOption.dirty. |
|
function description: string; virtual; |
Retrieve a description of the option.
The description returned was set when the option was first constructed and cannot be changed. It is most often presented to the user when the user requests help.
|
|
function valueDescription: string; virtual; |
Retrieve a description of the type of value accepted by the option.
The description returned was set when the option was first constructed and cannot be changed. It is most often presented to the user when the user requests help.
If no description of the value was provided when the option was first constructed, then this method will return the default value established by ACommandLineOption.init.
|
|
function optionDirtiedHandler: AnOptionDirtiedHandler; virtual; |
Retrieve a reference to the callback that should be invoked after all options have been parsed, but only if the option has been set.
|
Generated by PasDoc 0.13.0 on 2015-06-25 11:07:51
|