PHP Interface Webmozart\Console\Api\Args\RawArgs
Implementations of this class represent the arguments that a user passes
when calling the console. For example:
$ console server add --port 80 localhost
In this case, the raw arguments contain the tokens:
* "server"
* "add"
* "--port"
* "80"
* "localhost"
With an implementation of {@link ArgsParser} and a configured
{@link ArgsFormat}, the {@link RawArgs} instance can be converted into an
{@link Args} instance:
php
$format = ArgsFormat::build()
->addCommandName(new CommandName('server'))
->addCommandName(new CommandName('add'))
->addOption(new Option('port', 'p', Option::VALUE_REQUIRED | Option::INTEGER))
->addArgument(new Argument('host', Argument::REQUIRED))
->getFormat();
$args = $parser->parseArgs($rawArgs, $format);
The {@link Args} instance can be used to access the options and arguments of
a command in a convenient way.
Show file
Open project: webmozart/console
Interface Usage Examples
Public Methods
Method Details
getScriptName()
public method
Returns the PHP script as it was called on the console.
getTokens()
public method
Returns the tokens of the console arguments.
public getTokens ( ) : string[] |
return |
string[] |
The argument tokens. |
Returns whether the console arguments contain a given token.
Returns the console arguments as string.