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

Composer 2.4 (release pending) will have a completion script #211

Closed
dkarlovi opened this issue Jun 22, 2022 · 18 comments
Closed

Composer 2.4 (release pending) will have a completion script #211

dkarlovi opened this issue Jun 22, 2022 · 18 comments

Comments

@dkarlovi
Copy link

composer/composer#10320

Don't know when the release is planned.

@dkarlovi
Copy link
Author

Note, the same applies to all PHP tools based on Symfony Console 5.4+ since the feature is provided from there. I'm not sure what's the best way to add individual completion scripts though.

@remicollet
Copy link
Owner

Yes, I'm aware of this new feature.

Shoudl be as simple as dropping a /usr/share/bash-completion/completions/composer file in the package

Of course will take care of this when a beta/RC will be available.

@Seldaek
Copy link

Seldaek commented Jun 22, 2022

You can already do this, 2.3 should support it already AFAIK, but only for command names. 2.4 brings more advanced arg/option completion.

@remicollet
Copy link
Owner

@Seldaek indeed bash completion file is generated, but doesn't seems to do anything... more work needed here

@remicollet
Copy link
Owner

Added in the RPM for new release
https://git.remirepo.net/cgit/rpms/composer.git/commit/?id=8ce74cb1db085b4bfa20214084ab4903ce6f4e75

@dkarlovi
Copy link
Author

@remicollet that's awesome! \o/

@remicollet
Copy link
Owner

generated file is there

but doesn't seems to do anything..

@dkarlovi
Copy link
Author

You're right, I've just created it myself locally with 2.3.7 locally and it's not completing commands. It seems the command is exiting with an error.

The feature comes with a --debug flag which can be triggered like so

composer completion --debug

in one shell and use it in another (it's writing to a log file). Maybe @wouterj can help?

@Seldaek
Copy link

Seldaek commented Jun 22, 2022

You need to export SYMFONY_COMPLETION_DEBUG=1 in the shell doing the completion, and then the other shell running composer completion --debug should receive data.

Also make sure to try it with 2.4-dev with composer self-update --snapshot too if you really can't get it to work with 2.3.

@remicollet
Copy link
Owner

@dkarlovi version 2.4.0RC1 is not available in the testing repository, with bash completion working

$ composer in<tab><tab>
info     init     install  

@Seldaek this doesn't work with current symfony/console 5.4.10, need to be fixed, see symfony/symfony#47022

This probably also affects composer.phar if installed in the search path (ex: /usr/local/bin/composer) or as global installation (ex: $HOME/.composer/vendor/bin/composer)

@Seldaek
Copy link

Seldaek commented Jul 22, 2022

Not sure what doesn't work for you, it works fine for me, but anyway good to see you sent a PR. We'll update as soon as it gets released upstream.

@remicollet
Copy link
Owner

Not sure what doesn't work for you

If you use "composer" command (thanks to search path), then the [ -f "$sf_cmd" ] will fails.

@Seldaek
Copy link

Seldaek commented Jul 22, 2022

OK maybe it works for me because I use it from a local clone and not as a phar file? I don't quite grasp what your PR is fixing/doing sorry.

@Seldaek
Copy link

Seldaek commented Jul 22, 2022

Ah no sorry I see now what you mean. It worked for me because I always use it with my c alias, but when using composer it indeed fails without your patch 👍🏻

@dkarlovi
Copy link
Author

In the end, it's a good thing because the completion script (which is shared across all apps using Console) becomes more robust with each found corner case. 👍

@dkarlovi
Copy link
Author

@remicollet installed RC1 package, it works 🍾

@remicollet
Copy link
Owner

composer 2.4.0 is released and available in the repository

@dkarlovi
Copy link
Author

Thanks so much!

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

3 participants