Class TCommand

Unit

Declaration

type TCommand = class(TInterfacedObject, ICommand)

Description

Class that implements the ICommand interface that represents a command that can be registered in CommandBuilder for later use by the user.

Hierarchy

Overview

Methods

Public constructor Create;
Public function HasOptions: Boolean;
Public function AddOption(const AFlag, AName, ADescription: string; ANotAllowedFlags: TArray<string> = nil; AConstraint: TOptionConstraint = ocNoValue): IOption;
Public class function New(const AName, ADescription: string; ACallback: TCommandCallback; AConstraints: TCommandConstraints): ICommand;

Properties

Public property Name: string read GetName write SetName;
Public property Description: string read GetDescription write SetDescription;
Public property Callback: TCommandCallback read GetCallback write SetCallback;
Public property Constraints: TCommandConstraints read GetConstraints write SetConstraints;
Public property Option[constAIndex:string]: IOption read GetOption;
Public property Options: TArray<IOption> read GetOptions;

Description

Methods

Public constructor Create;

Basic class constructor. Use TCommand.New class factory as first option.

Public function HasOptions: Boolean;

Function that returns true if the command has at least one option configured.

Public function AddOption(const AFlag, AName, ADescription: string; ANotAllowedFlags: TArray<string> = nil; AConstraint: TOptionConstraint = ocNoValue): IOption;

Creates and adds the option to the command's list of options as given parameters.

Parameters
AFlag
Represents the option as a single letter, i.e. a short option
AName
Represents the option as a word, that is, a long option, it does not accept spaces, but "-' can be used for compound names. Ex: no-build
ADescription
Description of the option that best defines your objective. It can be displayed to the user when the user requests information through the help command for example
ANotAllowedFlags
Array of flags not supported for use in conjunction with this option. Only the short option without the "-" is accepted.
AConstraint
Option constraint that will be validated against the options provided by the user in order to guarantee that the command is being used correctly.
Public class function New(const AName, ADescription: string; ACallback: TCommandCallback; AConstraints: TCommandConstraints): ICommand;

Class factory recommended as first choice for class construction. Allows initialization with initial parameters.

Parameters
AName
Command name as it will be used via command line
ADescription
Command description that will be displayed to the user
ACallback
Callback procedure that will be invoked if this command was selected
AConstraints
Constraints check to validate correct command usage by the user.

Properties

Public property Name: string read GetName write SetName;

Name of the command that will be used via the command line by the user.

Public property Description: string read GetDescription write SetDescription;

Description of the command that best describes its purpose. It can be displayed to the user when he requests help information for the application.

Public property Callback: TCommandCallback read GetCallback write SetCallback;

Procedure that will be invoked by the builder after validation of the arguments provided by the user and the correct match of this command as the requested one.

Public property Constraints: TCommandConstraints read GetConstraints write SetConstraints;

Command constrains that will be validated against the arguments provided by the user in order to guarantee that the command is being used correctly.

Public property Option[constAIndex:string]: IOption read GetOption;

Retrieves an option given the index provided as a parameter.

Parameters
AIndex
Desired option index position
Public property Options: TArray<IOption> read GetOptions;

Property that returns the array of options defined for the command.


Generated by PasDoc 0.16.0.