8000 [Console][Completion] allow "signaling" from the completion command to the completion script · Issue #43608 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console][Completion] allow "signaling" from the completion command to the completion script #43608

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

Open
dkarlovi opened this issue Oct 20, 2021 · 6 comments

Comments

@dkarlovi
Copy link
Contributor
dkarlovi commented Oct 20, 2021

Description

Assuming #43607 is implemented (which implies a single signal, null), native filesystem is used as a fallback when Symfony doesn't have any completion to do (and doesn't explicitly say there's no matching values, the mentioned null signal).

Some values completed by native methods could get additional processing, for example the value could only be allowed to be a file path (not a directory), or matching a specific glob like *.twig (see #43594 (comment)).

Idea is to allow sending "signals" from the completion command to the completion script, which can then use those signals to do something special, not just dump the suggested values.

Example
1.

bin/console lint:twig | # trigger completion here
  1. "suggestion" dumped by completion command is (just an example, format would be anything easily parsed by shells)
compgen: type: file, glob: *.twig
  1. compgen gets invoked in a special way, not just the default, see https://www.linuxjournal.com/content/more-using-bash-complete-command

See #43594 (comment) for an outline of the workflow.

Note

If implemented, this feature must do a version check of the completion script. The version of the completion script is passed as a param to the completion command. This means these signals cannot be offered if the completion script was generated prior to the feature because it will offer the signals verbatim as suggestions to the end user.

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot
Copy link

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

@dkarlovi
Copy link
Contributor Author
dkarlovi commented May 5, 2022

Yes.

@GromNaN
Copy link
Member
GromNaN commented Jan 2, 2025

The logic for file path completion have been implemented in Castor: https://github.com/jolicode/castor/blob/ac7fa928eb2ebc093fe2eaacec275ef1c3174b1f/src/Console/Command/TaskCommand.php#L254

@dkarlovi
Copy link
Contributor Author
dkarlovi commented Jan 2, 2025

@GromNaN isn't this something that should use the shell features instead of implementing in PHP? Basically, the completion script should use the correct already existing shell completion, no?

@GromNaN
Copy link
Member
GromNaN commented Jan 2, 2025

I totally agree, it's a basic shell feature that can even have specific improvements. But Castor's approach works until we figure out how to do it better.

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

No branches or pull requests

5 participants
0