The parsed arguments provide access to the options and arguments passed via
the command line. Usually you can construct an {@link Args} instance by
parsing a {@link RawArgs} instance with an {@link ArgsParser}:
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 ArgsFormat} defines which rules the console arguments must adhere
to.
You can also create {@link Args} instances manually. This is especially
useful in tests:
php
$format = ArgsFormat::build()
->addOption(new Option('port', 'p', Option::VALUE_REQUIRED | Option::INTEGER))
->addArgument(new Argument('host', Argument::REQUIRED))
->getFormat();
$args = new Args($format);
$args->setOption('port', 80);
$args->setArgument('host', 'localhost');