-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Add ArgvInput::getRawTokens()
#54238
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicolas-grekas
approved these changes
Mar 14, 2024
stof
requested changes
Mar 14, 2024
29abff1
to
b5ab0e3
Compare
stof
approved these changes
Mar 14, 2024
Thank you @lyrixx. |
fabpot
added a commit
that referenced
this pull request
Mar 21, 2024
… name (lyrixx) This PR was merged into the 7.1 branch. Discussion ---------- [Console] Allow to return all tokens after the command name | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT follows #54238 Now, we can make it works at the command level (previous PR was at the application level) ```php #!/usr/bin/env php <?php use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Process\Process; require __DIR__ . '/vendor/autoload.php'; $command = new Command('ls'); $command->ignoreValidationErrors(); $command->setCode(function ($input) { $p = new Process(['ls', ...$input->getRawTokens(true)]); $p->setTty(true); $p->mustRun(); }); $app = new Application(); $app->add($command); $app->run(); ```  Commits ------- cef1979 [Console] Allow to returns all tokens after the command name
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many times, I had to access raw tokens, and each time I used reflection or other hacks
to get theses values. So I think it's time to expose this property properly.
For example, if you want to create a command that wrap a proces, with "pass thru" arguments,
you need that.
Examples:
Note
In castor, we also strip all options until the command name
It could be nice to add support for this too?