Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] Mention ArgvInput::getRawTokens #19713

Merged
merged 1 commit into from Apr 15, 2024

Conversation

alexandre-daubois
Copy link
Contributor

@alexandre-daubois alexandre-daubois commented Mar 26, 2024

Fix #19693, #19673

protected function execute(InputInterface $input, OutputInterface $output): int
{
// pass the raw input of your command to the "ls" command
$process = new Process(['ls', ...$input->getRawTokens(true)]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have problems understanding what "a token" is in this context.

Imagine that I run a command like this:

$ php bin/console app:my-command -c -a --foo --bar=zzz arg1 -- arg2 -b

Is this the content of getRawTokens()?

['-c', '-a', '--foo', '--bar=zzz', 'arg1', '--', 'arg2', '-b']

Also, what's the purpose of the boolean argument of getRawTokens()?

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is called a token because it can be anything: letters, pipes, dashes, etc. Not sure but that what makes the more sense to me 🙂

About the boolean argument, I wrote a sentence about it just under the code snippet. Should this also be present in the code snippet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will be back in 2 days, and I have an idea in mind. Will add a proposal then.

I am currently on a phone 📱

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end I merged this after rewording it a bit and expanding the code examples. If we don't like anything about this, let's create a new issue or PR. Thanks!

@javiereguiluz javiereguiluz merged commit e38e45b into symfony:7.1 Apr 15, 2024
3 checks passed
@javiereguiluz
Copy link
Member

Alex, thanks for this contribution!

I played with this option a bit locally to better understand it. That's why I reworded your contribution a bit while merging it (see a58dccf). I expanded the example a bit to show what exactly does the token array contain.

@alexandre-daubois
Copy link
Contributor Author

Thanks for the rewording!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console] Allow to return all tokens after the command name
4 participants