Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite38e45b

Browse files
committed
minor#19713 [Console] MentionArgvInput::getRawTokens (alexandre-daubois)
This PR was merged into the 7.1 branch.Discussion----------[Console] Mention `ArgvInput::getRawTokens`Fix#19693,#19673Commits-------7afdaa3 [Console] Mention `ArgvInput::getRawTokens`
2 parents7b591e0 +7afdaa3 commite38e45b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎console/input.rst‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,37 @@ The above code can be simplified as follows because ``false !== null``::
311311
$yell = ($optionValue !== false);
312312
$yellLouder = ($optionValue === 'louder');
313313

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+
314345
Adding Argument/Option Value Completion
315346
---------------------------------------
316347

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp