Methods |
public
|
load(): static
Prepare the option for use with a command
Prepare the option for use with a command
|
#
|
public
|
getJsonSchema(
): array{description?: string, type?: (string[]|string), enum?: array<string|int|bool|float|null>, items?: array{type?: (string[]|string), enum?: array<string|int|bool|float|null>}, uniqueItems?: bool, default?: (array<string|int|bool|float>|string|int|bool|float)}
Get the option's JSON Schema
Get the option's JSON Schema
Implements
|
#
|
public
|
getNames(): string[]
Get the option's names
|
#
|
public
|
getValueNameWords(): string
Get the option's value name as lowercase, space-separated words
Get the option's value name as lowercase, space-separated words
|
#
|
public
|
getValueName(bool $encloseUpper = false): string
Get the option's value name
Get the option's value name
- If {@see CliOption::$ValueName} contains one or more angle brackets, it
is returned as-is, e.g.
<key>=<VALUE>
- If it contains uppercase characters and no lowercase characters, it is
converted to kebab-case and capitalised, e.g.
VALUE-NAME
- Otherwise, it is converted to kebab-case and enclosed between angle
brackets, e.g.
<value-name>
If $encloseUpper is true , capitalised value names are enclosed
between angle brackets, e.g. <VALUE-NAME> .
In conversions to kebab-case, = is preserved.
|
#
|
public
|
formatAllowedValues(string $format = ' (one? of: {})'): string
Get the option's allowed values
Get the option's allowed values
Example: " (one or more of: first,last)"
Returns an empty string if the option doesn't have allowed values.
Parameters
$format |
"{}" is replaced with a delimited list of values,
and if {@see CliOption::$MultipleAllowed} is true , "?" is replaced
with " or more" .
|
|
#
|
public
|
getSummary(bool $withFullStop = true): ?string
Get the first paragraph of the option's description, unwrapping any line
breaks
Get the first paragraph of the option's description, unwrapping any line
breaks
|
#
|
public
|
maybeSplitValue<T is DateTimeImmutable|string|int|bool|float>(T[]|T|null $value): T[]
If a value is a non-empty string, split it on the option's delimiter,
otherwise wrap it in an array if needed
If a value is a non-empty string, split it on the option's delimiter,
otherwise wrap it in an array if needed
If $value is null or an empty string, an empty array is returned.
|
#
|
public
|
applyValue(
array<string|int|bool|float>|string|int|bool|float|null $value,
bool $normalise = true,
bool $expand = false,
): mixed
Normalise a value, assign it to the option's bound variable, and return
it to the caller
Normalise a value, assign it to the option's bound variable, and return
it to the caller
Parameters
$normalise |
false if $value has already been normalised.
|
$expand |
If true and the option has an optional value,
expand null or true to the default value of the option. Ignored if
$normalise is false .
|
|
#
|
public
|
normaliseValue(array<string|int|bool|float>|string|int|bool|float|null $value, bool $expand = false): mixed
If the option has a callback, apply it to a value, otherwise convert the
value to the option's value type
If the option has a callback, apply it to a value, otherwise convert the
value to the option's value type
Parameters
$expand |
If true and the option has an optional value,
expand null or true to the default value of the option.
|
|
#
|
public
|
normaliseValueForHelp(string|int|bool|float|null $value): string
Normalise a value for inclusion in a help message
Normalise a value for inclusion in a help message
|
#
|
Properties |
public
readonly
|
string|null
|
$Name
The name of the option
|
#
|
public
readonly
|
string|null
|
$Long
The long form of the option, e.g. "verbose"
The long form of the option, e.g. "verbose"
|
#
|
public
readonly
|
string|null
|
$Short
The short form of the option, e.g. "v"
The short form of the option, e.g. "v"
|
#
|
public
readonly
|
string
|
$Key
The option's internal identifier
The option's internal identifier
|
#
|
public
readonly
|
string|null
|
$ValueName
The name of the option's value as it appears in usage information
The name of the option's value as it appears in usage information
|
#
|
public
readonly
|
string
|
$DisplayName
The option's name as it appears in error messages
The option's name as it appears in error messages
|
#
|
public
readonly
|
string|null
|
$Description
A description of the option
A description of the option
|
#
|
public
readonly
|
CliOptionType::*
|
$OptionType
The option's type
|
#
|
public
readonly
|
bool
|
$IsFlag
True if the option is a flag
True if the option is a flag
|
#
|
public
readonly
|
bool
|
$IsOneOf
True if the option accepts values from a list
True if the option accepts values from a list
|
#
|
public
readonly
|
bool
|
$IsPositional
True if the option is positional
True if the option is positional
|
#
|
public
readonly
|
bool
|
$ValueRequired
True if the option has a mandatory value
True if the option has a mandatory value
|
#
|
public
readonly
|
bool
|
$ValueOptional
True if the option has an optional value
True if the option has an optional value
|
#
|
public
readonly
|
CliOptionValueType::*
|
$ValueType
The data type of the option's value
The data type of the option's value
|
#
|
public
readonly
|
array<string|int|bool|float>|null
|
$AllowedValues
The option's possible values, indexed by lowercase value if not case-sensitive
The option's possible values, indexed by lowercase value if not case-sensitive
|
#
|
public
readonly
|
bool
|
$CaseSensitive
True if the option's values are case-sensitive
True if the option's values are case-sensitive
|
#
|
public
readonly
|
CliOptionValueUnknownPolicy::*|null
|
$UnknownValuePolicy
The action taken if an unknown value is given
The action taken if an unknown value is given
|
#
|
public
readonly
|
bool
|
$Required
True if the option is mandatory
True if the option is mandatory
|
#
|
public
readonly
|
bool
|
$WasRequired
True if the option was mandatory before applying values from the environment
True if the option was mandatory before applying values from the environment
|
#
|
public
readonly
|
bool
|
$MultipleAllowed
True if the option may be given more than once
True if the option may be given more than once
|
#
|
public
readonly
|
bool
|
$Unique
True if the same value may not be given more than once
True if the same value may not be given more than once
|
#
|
public
readonly
|
bool
|
$AddAll
True if "ALL" should be added to the list of possible values when the option can be given more than once
True if "ALL" should be added to the list of possible values when the option can be given more than once
|
#
|
public
readonly
|
array<string|int|bool|float>|string|int|bool|float|null
|
$DefaultValue
Assigned to the option if no value is given on the command line
Assigned to the option if no value is given on the command line
|
#
|
public
readonly
|
array<string|int|bool|float>|string|int|bool|float|null
|
$OriginalDefaultValue
The option's default value before applying values from the environment
The option's default value before applying values from the environment
|
#
|
public
readonly
|
bool
|
$Nullable
True if the option's value should be null if it is not given on the command line
True if the option's value should be null if it is not given on the command line
|
#
|
public
readonly
|
string|null
|
$EnvVariable
The name of a value in the environment that replaces the option's default value
The name of a value in the environment that replaces the option's default value
|
#
|
public
readonly
|
non-empty-string|null
|
$Delimiter
The separator between values passed to the option as a single argument
The separator between values passed to the option as a single argument
|
#
|
public
readonly
|
(callable(array<string|int|bool|float>|string|int|bool|float): mixed)|null
|
$ValueCallback
Applied to the option's value as it is assigned
Applied to the option's value as it is assigned
|
#
|
public
readonly
|
int-mask-of<CliOptionVisibility::*>
|
$Visibility
The option's visibility to users
The option's visibility to users
|
#
|
public
readonly
|
bool
|
$IsBound
True if the option is bound to a variable
True if the option is bound to a variable
|
#
|