Property | Type | Description | |
---|---|---|---|
$color | whether to enable ANSI color in the output. If not set, ANSI color will only be enabled for terminals that support it. | ||
$help | whether to display help information about current command. | ||
$interactive | whether to run the command interactively. |
Method | Description | |
---|---|---|
ansiFormat ( string $string ) : string | Formats a string with ANSI codes | |
bindActionParams ( |
Binds the parameters to the action. | |
confirm ( string $message, boolean $default = false ) : boolean | Asks user to confirm by typing y or n. | |
getActionArgsHelp ( |
Returns the help information for the anonymous arguments for the action. | |
getActionHelp ( |
Returns the detailed help information for the specified action. | |
getActionHelpSummary ( |
Returns a one-line short summary describing the specified action. | |
getActionOptionsHelp ( |
Returns the help information for the options for the action. | |
getHelp ( ) : string | Returns help information for this controller. | |
getHelpSummary ( ) : string | Returns one-line short summary describing this controller. | |
getOptionValues ( string $actionID ) : array | Returns properties corresponding to the options for the action id Child classes may override this method to specify possible properties. | |
getPassedOptionValues ( ) : array | Returns the properties corresponding to the passed options | |
getPassedOptions ( ) : array | Returns the names of valid options passed during execution. | |
isColorEnabled ( resource $stream = STDOUT ) : boolean | Returns a value indicating whether ANSI color is enabled. | |
optionAliases ( ) : array | Returns option alias names. | |
options ( string $actionID ) : string[] | Returns the names of valid options for the action (id) An option requires the existence of a public member variable whose name is the option name. | |
prompt ( string $text, array $options = [] ) : string | Prompts the user for input and validates it | |
runAction ( string $id, array $params = [] ) : integer | Runs an action with the specified action ID and parameters. | |
select ( string $prompt, array $options = [] ) : string | Gives the user an option to choose from. Giving '?' as an input will show a list of options to choose from and their explanations. | |
stderr ( string $string ) : integer | boolean | Prints a string to STDERR | |
stdout ( string $string ) : integer | boolean | Prints a string to STDOUT |
Method | Description | |
---|---|---|
getActionMethodReflection ( |
||
parseDocCommentDetail ( Reflector $reflection ) : string | Returns full description from the docblock. | |
parseDocCommentSummary ( Reflector $reflection ) : string | Returns the first line of docblock. | |
parseDocCommentTags ( Reflector $reflection ) : array | Parses the comment block into tags. |
public ansiFormat ( string $string ) : string | ||
$string | string | the string to be formatted |
return | string |
public bindActionParams ( |
||
$action | the action to be bound with parameters | |
$params | array | the parameters to be bound to the action |
return | array | the valid parameters that the action can run with. |
public getActionArgsHelp ( |
||
$action | ||
return | array | the help information of the action arguments |
public getActionHelp ( |
||
$action | action to get help for | |
return | string | the detailed help information for the specified action. |
public getActionHelpSummary ( |
||
$action | action to get summary for | |
return | string | a one-line short summary describing the specified action. |
protected getActionMethodReflection ( |
||
$action | ||
return | ReflectionMethod |
public getActionOptionsHelp ( |
||
$action | ||
return | array | the help information of the action options |
public getHelpSummary ( ) : string | ||
return | string |
public getOptionValues ( string $actionID ) : array | ||
$actionID | string | the action id of the current request |
return | array | properties corresponding to the options for the action |
public getPassedOptionValues ( ) : array | ||
return | array | the properties corresponding to the passed options |
public getPassedOptions ( ) : array | ||
return | array | the names of the options passed during execution |
public isColorEnabled ( resource $stream = STDOUT ) : boolean | ||
$stream | resource | the stream to check. |
return | boolean | Whether to enable ANSI style in output. |
public optionAliases ( ) : array | ||
return | array | the options alias names valid for the action where the keys is alias name for option and value is option name. |
protected parseDocCommentDetail ( Reflector $reflection ) : string | ||
$reflection | Reflector | |
return | string |
protected parseDocCommentSummary ( Reflector $reflection ) : string | ||
$reflection | Reflector | |
return | string |
protected parseDocCommentTags ( Reflector $reflection ) : array | ||
$reflection | Reflector | the comment block |
return | array | the parsed tags |
public prompt ( string $text, array $options = [] ) : string | ||
$text | string | prompt string |
$options | array | the options to validate the input: - required: whether it is required or not - default: default value if no input is inserted by the user - pattern: regular expression pattern to validate user input - validator: a callable function to validate input. The function must accept two parameters: - $input: the user input to validate - $error: the error value passed by reference if validation failed. An example of how to use the prompt method with a validator function. ```php $code = $this->prompt('Enter 4-Chars-Pin', ['required' => true, 'validator' => function($input, &$error) { if (strlen($input) !== 4) { $error = 'The Pin must be exactly 4 chars!'; return false; } return true; }); ``` |
return | string | the user input |
public $color |