Class ACommandLineChoice

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ACommandLineChoice = class(ACommandLineOption)

Description

This class represents a command-line option that expects a value to be chosen from a list of pre-defined values.

If the user supplies a value which is not in ACommandLineChoice.AcceptedValues, then an error is returned to them.

Hierarchy

Overview

Fields

Protected MyAcceptedValues: AVariantList;

Methods

Public constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const theseValuesAccepted: array of const; const thisDescription: string; const thisValueDescription: string = ''); reintroduce; virtual;
Public function init: boolean; override;
Public destructor destroy; override;
Public function usageString: AnsiString; override;
Public function AcceptedValues: AVariantList; virtual;
Public function setValue(const newValue: Variant; const makeDirty: boolean = true): Variant; override;

Description

Fields

Protected MyAcceptedValues: AVariantList;

Refers to the list of allowed values

Methods

Public constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const theseValuesAccepted: array of const; const thisDescription: string; const thisValueDescription: string = ''); reintroduce; virtual;

Construct a new command-line option with the specified name.

This method constructs a new instance of ACommandLineOption with the specified defaultValue and theseValuesAccepted. 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.

Public function init: boolean; override;

Initializer

Public destructor destroy; override;

Destroy the option.

This method frees the values in ACommandLineChoice.AcceptedValues and then calls the inherited routine.

Public function usageString: AnsiString; override;

Construct and return a string representation of the option, suitable for output to a text-based device, such as a console.

This method builds upon the behavior inherited from ACommandLineOption.usageString: it calls that routine first, then appends a string that indicates the acceptable values for the option. The format of the appended string is controlled by clchAcceptedValuesDescription.

Public function AcceptedValues: AVariantList; virtual;

Retrieve a reference to the list of values allowed for the option. The caller should NOT attempt to free this reference; that will be done when the option itself is freed.

Public function setValue(const newValue: Variant; const makeDirty: boolean = true): Variant; override;

Set the value of the option.

This method overrides the behavior inherited from ACommandLineOption.setValue. It checks to ensure that newValue is in the list of values specified by Self.AcceptedValues. If not, the value is not set and an exception is raised.

Returns

The previous value of ACommandLineChoice.value.

Exceptions raised
AnOptionValueError
if newValue specifies a value that is not in the list of accepted values.

Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18