PHP 클래스 Webmozart\Console\Api\Command\Command

A Command object contains all the information that is necessary to describe and run a console command. Use the {@link CommandConfig} class to configure a command: php $config = CommandConfig::create() ->setDescription('List and manage servers') ->beginSubCommand('add') ->setDescription('Add a new server') ->addArgument('host', InputArgument::REQUIRED) ->addOption('port', 'p', InputOption::VALUE_OPTIONAL, null, 80) ->end() ; $command = new Command($config);
부터: 1.0
저자: Bernhard Schussek ([email protected])
파일 보기 프로젝트 열기: webmozart/console 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( CommandConfig $config, Webmozart\Console\Api\Application\Application $application = null, Command $parentCommand = null ) Creates a new command.
getAliases ( ) : string[] Returns the alias names of the command.
getApplication ( ) : Webmozart\Console\Api\Application\Application Returns the console application.
getArgsFormat ( ) : ArgsFormat Returns the arguments format of the command.
getConfig ( ) : CommandConfig Returns the configuration of the command.
getDefaultSubCommands ( ) : CommandCollection Returns the commands that should be executed if no explicit command is passed.
getName ( ) : string Returns the name of the command.
getNamedSubCommands ( ) : CommandCollection Returns all sub-commands that are not anonymous.
getParentCommand ( ) : Command Returns the parent command.
getShortName ( ) : string | null Returns the short name of the command.
getSubCommand ( string $name ) : Command Returns the sub-command with a specific name.
getSubCommands ( ) : CommandCollection Returns all sub-commands of the command.
handle ( Args $args, IO $io ) : integer Executes the command for the given parsed arguments.
hasAliases ( ) : boolean Returns whether the command has aliases.
hasDefaultSubCommands ( ) : boolean Returns whether the command has any default commands.
hasNamedSubCommands ( ) : boolean Returns whether the command has any commands that are not anonymous.
hasSubCommand ( string $name ) : boolean Returns whether a sub-command with the given name exists.
hasSubCommands ( ) : boolean Returns whether the command has any sub-commands.
parseArgs ( Webmozart\Console\Api\Args\RawArgs $args, boolean $lenient = null ) : Args Parses the raw console arguments and returns the parsed arguments.
run ( Webmozart\Console\Api\Args\RawArgs $args, IO $io ) : integer Executes the command for the given unparsed arguments.

비공개 메소드들

메소드 설명
addSubCommand ( SubCommandConfig $config ) Adds a sub-command.
doHandle ( Args $args, IO $io )
getBaseFormat ( ) : ArgsFormat Returns the inherited arguments format of the command.
validateSubCommandName ( SubCommandConfig $config )
warnIfProcessTitleNotSupported ( $processTitle, IO $io )

메소드 상세

__construct() 공개 메소드

Creates a new command.
public __construct ( CommandConfig $config, Webmozart\Console\Api\Application\Application $application = null, Command $parentCommand = null )
$config Webmozart\Console\Api\Config\CommandConfig The command configuration.
$application Webmozart\Console\Api\Application\Application The console application.
$parentCommand Command The parent command.

getAliases() 공개 메소드

Returns the alias names of the command.
public getAliases ( ) : string[]
리턴 string[] An array of alias names of the command.

getApplication() 공개 메소드

Returns the console application.
public getApplication ( ) : Webmozart\Console\Api\Application\Application
리턴 Webmozart\Console\Api\Application\Application The console application.

getArgsFormat() 공개 메소드

Returns the arguments format of the command.
public getArgsFormat ( ) : ArgsFormat
리턴 Webmozart\Console\Api\Args\Format\ArgsFormat The input definition.

getConfig() 공개 메소드

Returns the configuration of the command.
public getConfig ( ) : CommandConfig
리턴 Webmozart\Console\Api\Config\CommandConfig The command configuration.

getDefaultSubCommands() 공개 메소드

Returns the commands that should be executed if no explicit command is passed.
public getDefaultSubCommands ( ) : CommandCollection
리턴 CommandCollection The default commands.

getName() 공개 메소드

Returns the name of the command.
public getName ( ) : string
리턴 string The name of the command.

getNamedSubCommands() 공개 메소드

Returns all sub-commands that are not anonymous.
public getNamedSubCommands ( ) : CommandCollection
리턴 CommandCollection The named commands.

getParentCommand() 공개 메소드

Returns the parent command.
public getParentCommand ( ) : Command
리턴 Command The parent command.

getShortName() 공개 메소드

This method only returns a value if an {@link OptionCommandConfig} was passed to the constructor. Otherwise this method returns null.
public getShortName ( ) : string | null
리턴 string | null The short name or `null` if the command is not an option command.

getSubCommand() 공개 메소드

Returns the sub-command with a specific name.
public getSubCommand ( string $name ) : Command
$name string The name of the sub-command.
리턴 Command The sub-command.

getSubCommands() 공개 메소드

Returns all sub-commands of the command.
public getSubCommands ( ) : CommandCollection
리턴 CommandCollection The sub-commands.

handle() 공개 메소드

Executes the command for the given parsed arguments.
public handle ( Args $args, IO $io ) : integer
$args Webmozart\Console\Api\Args\Args The parsed console arguments.
$io Webmozart\Console\Api\IO\IO The I/O.
리턴 integer Returns 0 on success and any other integer on error.

hasAliases() 공개 메소드

Returns whether the command has aliases.
public hasAliases ( ) : boolean
리턴 boolean Returns `true` if the command has aliases and `false` otherwise.

hasDefaultSubCommands() 공개 메소드

Returns whether the command has any default commands.
또한 보기: getDefaultSubCommands()
public hasDefaultSubCommands ( ) : boolean
리턴 boolean Returns `true` if the command has default commands and `false` otherwise.

hasNamedSubCommands() 공개 메소드

Returns whether the command has any commands that are not anonymous.
또한 보기: getNamedSubCommands()
public hasNamedSubCommands ( ) : boolean
리턴 boolean Returns `true` if the command has named commands and `false` otherwise.

hasSubCommand() 공개 메소드

Returns whether a sub-command with the given name exists.
public hasSubCommand ( string $name ) : boolean
$name string The name of the sub-command.
리턴 boolean Returns `true` if a sub-command with that name exists and `false` otherwise.

hasSubCommands() 공개 메소드

Returns whether the command has any sub-commands.
public hasSubCommands ( ) : boolean
리턴 boolean Returns `true` if the command has sub-commands and `false` otherwise.

parseArgs() 공개 메소드

Parses the raw console arguments and returns the parsed arguments.
public parseArgs ( Webmozart\Console\Api\Args\RawArgs $args, boolean $lenient = null ) : Args
$args Webmozart\Console\Api\Args\RawArgs The raw console arguments.
$lenient boolean Whether the parser should ignore parse errors. If `true`, the parser will not throw any exceptions when parse errors occur.
리턴 Webmozart\Console\Api\Args\Args The parsed console arguments.

run() 공개 메소드

Executes the command for the given unparsed arguments.
public run ( Webmozart\Console\Api\Args\RawArgs $args, IO $io ) : integer
$args Webmozart\Console\Api\Args\RawArgs The unparsed console arguments.
$io Webmozart\Console\Api\IO\IO The I/O.
리턴 integer Returns 0 on success and any other integer on error.