class Command (View source)

Constants

ARG_NO_VALUE

ARG_OPTIONAL

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 $short = null, string $mode = self::ARG_OPTIONAL, string $format = null, string $description = null)

Define a option for command

enableResidual(bool $enable)

If set to true, it will allow the command to receive invalid parameters, which will be passed to the third parameter of the callback

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 $short = null, string $mode = self::ARG_OPTIONAL, string $format = null, string $description = null)

Define a option for command

Parameters

string $long

Define long option, used with -- prefix

string $short

Optional. Define short option, used with - prefix

string $mode

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

string $format

Optional. Define format excepted of value (not work with ARG_NO_VALUE)

string $description

Optional. Define a description for option

Return Value

Command

Command enableResidual(bool $enable)

If set to true, it will allow the command to receive invalid parameters, which will be passed to the third parameter of the callback

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