namespace Symfony\Component\Console\Input;
use Symfony\Component\Console\Exception\RuntimeException;
class ArgvInput extends Input
{
protected function parse()
{
$parseOptions = true;
$this->parsed = $this->tokens;
+ if (in_array('--', $this->tokens)) { // if $this->allowsExtraArgs() && $this->hasExtraArgs()
+ $this->parsed = array_slice($this->tokens, 0, array_search('--', $this->tokens));
+
+ $extra = array_slice($this->tokens, array_search('--', $this->tokens) + 1);
+
+ $this->options['--command'] = implode(' ', $extra);
+ }
while (null !== $token = array_shift($this->parsed)) {
$parseOptions = $this->parseToken($token, $parseOptions);
}
}
}
use Symfony\Component\Console\Command\Command;
class Demo extends Command
{
protected function configure(): void
{
$this->setDefinition(
new InputDefinition([
// ...
// new InputOption('--command', '-c', InputOption::VALUE_OPTIONAL, 'Raw Command'),
])
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
dd($input->getOption('--command')); // cmd arg --opt=ok
}
}
php artisan xml:lint in.xml --noout -- cmd arg --opt=ok