Overview

Namespaces

  • Webmozart
    • Console
      • Adapter
      • Api
        • Application
        • Args
          • Format
        • Command
        • Config
        • Event
        • Formatter
        • IO
        • Resolver
      • Args
      • Config
      • Formatter
      • Handler
        • Help
      • IO
        • InputStream
        • OutputStream
      • Process
      • Resolver
      • UI
        • Alignment
        • Component
        • Help
        • Layout
        • Style
      • Util

Classes

  • Args

Interfaces

  • ArgsParser
  • RawArgs

Exceptions

  • CannotAddArgumentException
  • CannotAddOptionException
  • CannotParseArgsException
  • NoSuchArgumentException
  • NoSuchOptionException
  • Overview
  • Namespace
  • Class

Interface RawArgs

The unparsed console arguments.

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 Webmozart\Console\Api\Args\ArgsParser and a configured ArgsFormat, the Webmozart\Console\Api\Args\RawArgs instance can be converted into an Webmozart\Console\Api\Args\Args instance:

$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 Webmozart\Console\Api\Args\Args instance can be used to access the options and arguments of a command in a convenient way.

Direct known implementers

Webmozart\Console\Args\ArgvArgs, Webmozart\Console\Args\StringArgs
Namespace: Webmozart\Console\Api\Args
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
See: Webmozart\Console\Api\Args\Args, ArgsFormat, Webmozart\Console\Api\Args\ArgsParser
Located at Api/Args/RawArgs.php
Methods summary
public string|null
# getScriptName( )

Returns the PHP script as it was called on the console.

Returns the PHP script as it was called on the console.

Returns

string|null

The script name or null if no script name is available.

public string[]
# getTokens( )

Returns the tokens of the console arguments.

Returns the tokens of the console arguments.

Returns

string[]
The argument tokens.
public boolean
# hasToken( string $token )

Returns whether the console arguments contain a given token.

Returns whether the console arguments contain a given token.

Parameters

$token
The token to look for.

Returns

boolean

Returns true if the arguments contain the token and false otherwise.

public string
# toString( boolean $scriptName = true )

Returns the console arguments as string.

Returns the console arguments as string.

Parameters

$scriptName
Whether to include the script name in the output.

Returns

string
The arguments as string.
Webmozart Console API API documentation generated by ApiGen