File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,37 @@ The above code can be simplified as follows because ``false !== null``::
311
311
$yell = ($optionValue !== false);
312
312
$yellLouder = ($optionValue === 'louder');
313
313
314
+ Fetching The Raw Command Input
315
+ ------------------------------
316
+
317
+ Sometimes, you may need to fetch the raw input that was passed to the command.
318
+ This is useful when you need to parse the input yourself or when you need to
319
+ pass the input to another command without having to worry about the number
320
+ of arguments or options defined in your own command. This can be achieved
321
+ thanks to the
322
+ :method: `Symfony\\ Component\\ Console\\ Input\\ ArgvInput::getRawTokens ` method::
323
+
324
+ // ...
325
+ use Symfony\Component\Process\Process;
326
+
327
+ protected function execute(InputInterface $input, OutputInterface $output): int
328
+ {
329
+ // pass the raw input of your command to the "ls" command
330
+ $process = new Process(['ls', ...$input->getRawTokens(true)]);
331
+ $process->setTty(true);
332
+ $process->mustRun();
333
+
334
+ // ...
335
+ }
336
+
337
+ You can include the current command name in the raw tokens by passing ``true ``
338
+ to the ``getRawTokens `` method only parameter.
339
+
340
+ .. versionadded :: 7.1
341
+
342
+ The :method: `Symfony\\ Component\\ Console\\ Input\\ ArgvInput::getRawTokens `
343
+ method was introduced in Symfony 7.1.
344
+
314
345
Adding Argument/Option Value Completion
315
346
---------------------------------------
316
347
You can’t perform that action at this time.
0 commit comments