stecman / composer-bash-completion-plugin Goto Github PK
View Code? Open in Web Editor NEWA hacky composer plugin to add bash completion without changing Composer code
A hacky composer plugin to add bash completion without changing Composer code
To get list of custom scripts:
composer run-script -l
Or some php -r 'var_dump(array_keys(json_decode(file_get_contents("composer.json"), true)["scripts"]));'
Currently the snippets don't make use of the alternative home-directory when the environment variable COMPOSER_HOME is set.
Thanks for enabling Composer 2 support so quickly. However, now I'm getting conflicts with other packages due to the required symfony/console
version.
$ composer global require stecman/composer-bash-completion-plugin dev-master
Changed current directory to /home/chris/.config/composer
./composer.json has been updated
Running composer update stecman/composer-bash-completion-plugin
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- stecman/symfony-console-completion 0.7.0 requires symfony/console ~2.3 || ~3.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.45] but the package is fixed to v5.1.7 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- stecman/composer-bash-completion-plugin dev-master requires stecman/symfony-console-completion ~0.7.0 -> satisfiable by stecman/symfony-console-completion[0.7.0].
- Root composer.json requires stecman/composer-bash-completion-plugin dev-master -> satisfiable by stecman/composer-bash-completion-plugin[dev-master].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I believe this is due to the "stecman/symfony-console-completion": "~0.7.0"
dependency. It looks like you have an updated version that supports newer Symfony package versions though. I'm not sure but updating this dependency might be all you need to do to fix that.
Currently composer global ...
doesn't provide any suggestions.
It would be nice to have the zsh and bash completion snippets in distinct files.
Along with the possibility to directly download these and copy/symlink them to:
/usr/local/share/zsh/site-functions # zsh
/usr/share/bash-completion/completions/ # bash
Further it would make it easier to send pull requests with improvements.
Composer 2 was just released and this plugin doesn't seem to be compatible. When running composoer global update I'm seeing the following output
$ composer global update
Changed current directory to /home/chris/.config/composer
The "stecman/composer-bash-completion-plugin" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires stecman/composer-bash-completion-plugin dev-master -> satisfiable by stecman/composer-bash-completion-plugin[dev-master].
- stecman/composer-bash-completion-plugin dev-master requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
Also, when attempting to tab complete something the following is printed to the terminal
The "stecman/composer-bash-completion-plugin" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
[InvalidArgumentException]
Could not find package "_completion" in your project
depends [-r|--recursive] [-t|--tree] [--] <package> [<constraint>]
Hey Stephen,
first of all ... let me thank you for that awesome plugin. The idea of fetching valid suggestions from the available *Command
s and InputOption
s is brilliant and logical.
I've seen other completion functions capable of providing completions for the require
command by using a (cached) result of composer show
.
composer show -a | grep -v '^No composer'
... can be used to find all available packages without the line ...
No composer.json found in the current directory, showing available packages from packagist
... if composer is executed inside a directory that has no composer.json
.
I didn't have the time to dive into the code of the CompletionCommand
yet.
Would you rather add something like this in the bash/zsh-snippets or do this in PHP with a ComposerCompletionCommand
that extends CompletionCommand
added to this repository?
There are currently no suggestions for composer help ...
.
It would be nice to complete composer remove
and composer update
with the resultset of:
composer <global> show --self --no-ansi
This is the list of local requires along with some other information. An example command to find all requires
and requires (dev)
in the output would be:
composer global show --self --no-ansi \
| sed -n '/^requires\(\s(.*)\)*$/d' -e '/^$/,$p' \
| sed -e '/^requires\(\s(.*)\)*$/d' -e '/^$/d' \
| awk '{print $1;}'
This:
Pretty sure it can be improved but it works flawlessly throughout all test-runs i made (only requires, only dev-requires, ...).
I've been seeing the following error lately when I'd expect to see completion results.
$ composer <Tab> <Tab>
[Symfony\Component\Console\Exception\RuntimeException]
The "--shell-type" option does not exist.
depends [-r|--recursive] [-t|--tree] [--] <package>
Running Arch Linux.
$ php --version
PHP 8.0.10 (cli) (built: Aug 26 2021 10:26:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
$ composer global show --direct
Changed current directory to /home/chris/.config/composer
beyondcode/expose 2.0.2 Create public URLs for local sites through any firewall and VPN.
friendsofphp/php-cs-fixer v3.1.0 A tool to automatically fix PHP code style
laravel/installer v4.2.8 Laravel application installer.
psy/psysh v0.10.8 An interactive shell for modern PHP.
squizlabs/php_codesniffer 3.6.0 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a...
stecman/composer-bash-completion-plugin dev-master 14b1ef5 BASH/ZSH auto-complete plugin for Composer
https://github.com/stecman/composer-bash-completion-plugin/blob/master/composer.json#L12
In result, it keeps dependency of the old symfony/console
:
stecman/symfony-console-completion 0.7.0 requires symfony/console (~2.3 || ~3.0)
On Debian, default composer dir is $HOME/.config/composer
.
The plugin is not loaded due to this commit composer/composer@0627d84
Please try, for example,
composer global require stecman/composer-bash-completion-plugin dev-master
composer global require ovr/phpsa
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.