class Command (View source)

Constants

ARG_NO_VALUE

ARG_REQUIRED

REGEX_NAME

REGEX_LONG

REGEX_SHORT

Methods

__construct(string $name, string|callable $callback)

Creates a command to be used with an Inphinit\Cli\Console instance

setOption(string $long, string|null $short = null, int $modes = 0, string|null $pattern = null, string|null $description = null)

Define a option for command

enableResidues(bool $enable)

If set to true, entries that don't match any declared option will be collected as residues and passed to the third parameter of the callback, instead of throwing an exception.

restrictToCli(bool $enable)

If True, the command can only be executed in CLI

string
getName()

They get the name from the command

array
getOptions()

They obtain the (long) options that the command accepts

array
getShortOptions()

They obtain the short options that are equivalent to the (long) options

mixed
response(array $entries)

This method will be used automatically by the Inphinit\Cli\Console instance

Details

__construct(string $name, string|callable $callback)

Creates a command to be used with an Inphinit\Cli\Console instance

Parameters

string $name
string|callable $callback

Exceptions

Exception

Command setOption(string $long, string|null $short = null, int $modes = 0, string|null $pattern = null, string|null $description = null)

Define a option for command

Parameters

string $long

Define long option, used with -- prefix

string|null $short

Optional. Define short option, used with - prefix

int $modes

Optional. Define whether the option is optional, required, or should be used without a value

string|null $pattern

Optional. Define expected value format (not work with ARG_NO_VALUE)

string|null $description

Optional. Define option description

Return Value

Command

Exceptions

Exception

Command enableResidues(bool $enable)

If set to true, entries that don't match any declared option will be collected as residues and passed to the third parameter of the callback, instead of throwing an exception.

Parameters

bool $enable

Return Value

Command

Exceptions

Exception

Command restrictToCli(bool $enable)

If True, the command can only be executed in CLI

Parameters

bool $enable

Return Value

Command

Exceptions

Exception

string getName()

They get the name from the command

Return Value

string

array getOptions()

They obtain the (long) options that the command accepts

Return Value

array

array getShortOptions()

They obtain the short options that are equivalent to the (long) options

Return Value

array

mixed response(array $entries)

This method will be used automatically by the Inphinit\Cli\Console instance

Parameters

array $entries

Return Value

mixed

Exceptions

Exception