Console class
Framework\CLI\Console
Class Console.
Defined in libraries/cli/src/Console.php
Properties #
- $commands
- List of commands.
- $command
- The current command name.
- $options
- Input options.
- $arguments
- Input arguments.
- $language
- The Language instance.
$commands
List of commands.
$command
The current command name.
$options
Input options.
$arguments
Input arguments.
$language
The Language instance.
Methods #
- __construct()
- Console constructor.
- addCommand()
- Add a command to the console.
- addCommands()
- Add many commands to the console.
- commandToArgs()
- -
- exec()
- -
- getArgument()
- Get a specific argument or null.
- getArguments()
- Get all arguments.
- getCommand()
- Get an active command.
- getCommands()
- Get a list of active commands.
- getLanguage()
- Get the Language instance.
- getOption()
- Get a specific option or null.
- getOptions()
- Get all CLI options.
- hasCommand()
- Tells if it has a command.
- removeCommand()
- Remove a command.
- removeCommands()
- Remove commands.
- run()
- Run the Console.
- setLanguage()
- Set the Language instance.
- prepare()
- Prepare information of the command line.
- reset()
- -
- setDefaultCommands()
- -
__construct()
Console constructor.
- ?\Framework\Language\Language $language
addCommand()
Add a command to the console.
- \Framework\CLI\Command|string $command - A Command instance or the class FQN
addCommands()
Add many commands to the console.
- array $commands - A list of Command instances or the classes FQN
commandToArgs()
- string $command
exec()
- string $command
getArgument()
Get a specific argument or null.
- int $position - Argument position, starting from zero
getArguments()
Get all arguments.
getCommand()
Get an active command.
- string $name - Command name
getCommands()
Get a list of active commands.
getLanguage()
Get the Language instance.
getOption()
Get a specific option or null.
- string $option
getOptions()
Get all CLI options.
hasCommand()
Tells if it has a command.
- string $name - Command name
removeCommand()
Remove a command.
- string $name - Command name
removeCommands()
Remove commands.
- array $names - Command names
run()
Run the Console.
setLanguage()
Set the Language instance.
- ?\Framework\Language\Language $language
prepare()
Prepare information of the command line.
[options] [arguments] [options]
[options] -- [arguments]
[command]
[command] [options] [arguments] [options]
[command] [options] -- [arguments]
Short option: -l, -la === l = true, a = true
Long option: --list, --all=vertical === list = true, all = vertical
Only Long Options receive values:
--foo=bar or --f=bar - "foo" and "f" are bar
-foo=bar or -f=bar - all characters are true (f, o, =, b, a, r)
After -- all values are arguments, also if is prefixed with -
Without --, arguments and options can be mixed: -ls foo -x abc --a=e.
- array $argumentValues