Command
class Command extends AbstractCommand (View source)
Base Command class.
Methods
Console constructor.
Add an argument(sub command) setting. This method in Command use 'self' instead 'static' to make sure every sub command add Command class as arguments.
Get argument by offset or return default.
Alias of addCommand if someone think child is more semantic.
Get a argument(command) by name path.
Batch set children (sub commands).
Add a option object to this command.
Add a option object to this command.
Get value from an option.
set the option alias.
The command description setter.
Sets the usage to tell user how to use this command.
Render auto complete alternatives.
Write a string to standard output.
Write a string to standard error output.
Set child command, note the key is no use, we use command name as key.
Details
in AbstractCommand at line line 137
__construct(string $name = null, IOInterface $io = null, AbstractCommand $parent = null)
Console constructor.
in AbstractCommand at line line 162
mixed
execute()
Execute this command.
in AbstractCommand at line line 313
IOInterface
getIO()
Method to get property Io
in AbstractCommand at line line 325
AbstractCommand
setIO(IOInterface $io)
Method to set property io
in AbstractCommand at line line 341
AbstractCommand
setParent(AbstractCommand $parent = null)
Parent command setter.
in AbstractCommand at line line 355
AbstractCommand
getParent()
Get Parent Command.
at line line 50
AbstractCommand
addCommand(string|AbstractCommand $command, string $description = null, Option[] $options = array(), Closure $code = null)
Add an argument(sub command) setting. This method in Command use 'self' instead 'static' to make sure every sub command add Command class as arguments.
in AbstractCommand at line line 429
null|string
getArgument(int $offset, callable|mixed $default = null)
Get argument by offset or return default.
in AbstractCommand at line line 459
AbstractCommand
addChild(string|AbstractCommand $argument, string $description = null, Option[] $options = array(), Closure $handler = null)
Alias of addCommand if someone think child is more semantic.
in AbstractCommand at line line 473
AbstractCommand|null
getChild(string $path)
Get a argument(command) by name path.
in AbstractCommand at line line 501
array
getChildren()
Get children array.
in AbstractCommand at line line 515
AbstractCommand
setChildren(array $children)
Batch set children (sub commands).
in AbstractCommand at line line 539
Option
addOption(mixed $option, mixed $default = null, string $description = null)
Add a option object to this command.
in AbstractCommand at line line 572
Option
addGlobalOption(mixed $option, mixed $default = null, string $description = null)
Add a option object to this command.
in AbstractCommand at line line 611
mixed
getOption(string $name, string $default = null)
Get value from an option.
If the name not found, we use alias to find options.
in AbstractCommand at line line 649
Option[]
getOptions(boolean $global = false)
Get options as array.
in AbstractCommand at line line 663
OptionSet
getOptionSet(boolean $global = false)
Get option set object.
in AbstractCommand at line line 675
array
getAllOptions()
Get all options include global.
in AbstractCommand at line line 689
AbstractCommand
setOptions(mixed $options)
Batch add options to command.
in AbstractCommand at line line 712
AbstractCommand
setOptionAliases(mixed $aliases, string $name, bool $global = false)
set the option alias.
in AbstractCommand at line line 733
string
getDescription()
The command description getter.
in AbstractCommand at line line 747
AbstractCommand
description(string $description)
The command description setter.
in AbstractCommand at line line 761
string
getName()
Console name getter.
in AbstractCommand at line line 775
AbstractCommand
setName(string $name)
Console name setter.
in AbstractCommand at line line 789
Closure
getHandler()
Console execute code getter.
in AbstractCommand at line line 803
AbstractCommand
handler(callable $handler = null)
Console execute code setter.
in AbstractCommand at line line 817
Console
getApplication()
Get the application.
in AbstractCommand at line line 831
AbstractCommand
setApplication(Console $application)
Set the application.
in AbstractCommand at line line 845
string
getHelp()
Get the help manual.
in AbstractCommand at line line 859
AbstractCommand
help(string $help)
Sets the help manual
in AbstractCommand at line line 873
string
getUsage()
Get the usage.
in AbstractCommand at line line 887
AbstractCommand
usage(string $usage)
Sets the usage to tell user how to use this command.
in AbstractCommand at line line 904
void
renderAlternatives(string $wrongName, CommandNotFoundException $exception)
Render auto complete alternatives.
in AbstractCommand at line line 953
void
renderException(Exception $exception)
Render exception for debugging.
in AbstractCommand at line line 988
void
error(Exception|string $exception)
Raise error message.
in AbstractCommand at line line 1008
AbstractCommand
out(string $text = '', boolean $nl = true)
Write a string to standard output.
in AbstractCommand at line line 1030
AbstractCommand
err(string $text = '', boolean $nl = true)
Write a string to standard error output.
in AbstractCommand at line line 1046
string
in(string $question = '')
Get a value from standard input.
in AbstractCommand at line line 1066
void
offsetSet(mixed $offset, AbstractCommand $value)
Set child command, note the key is no use, we use command name as key.
in AbstractCommand at line line 1080
boolean
offsetExists(string $offset)
Is a child exists?
in AbstractCommand at line line 1094
void
offsetUnset(string $offset)
Unset a child command.
in AbstractCommand at line line 1108
AbstractCommand|null
offsetGet(string $offset)
Get a command by name.