mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Add script completion for composer
When no command is given or when using "run-script" parse composer.json and look for the "scripts" section. Complete script names.
This commit is contained in:
parent
d740b2a473
commit
6ce03a4a36
1 changed files with 16 additions and 0 deletions
|
@ -48,6 +48,18 @@ print \"\n\".join(installed_packages)
|
|||
" | python
|
||||
end
|
||||
|
||||
function __fish_composer_scripts
|
||||
test -f composer.json; or return
|
||||
echo "
|
||||
import json
|
||||
json_data = open('composer.json')
|
||||
data = json.load(json_data)
|
||||
json_data.close()
|
||||
if 'scripts' in data and data['scripts']:
|
||||
print \"\n\".join(data['scripts'].keys())
|
||||
" | python
|
||||
end
|
||||
|
||||
#add cmds list
|
||||
set --local composer_cmds 'about' 'archive' 'browse' 'clear-cache' 'clearcache' 'config' 'create-project' 'depends' 'diagnose' 'dump-autoload' 'dumpautoload' 'global' 'help' 'home' 'init' 'install' 'licenses' 'list' 'remove' 'require' 'run-script' 'search' 'self-update' 'selfupdate' 'show' 'status' 'update' 'validate'
|
||||
|
||||
|
@ -65,6 +77,10 @@ complete -f -c composer -n '__fish_composer_using_command why' -a "(__fish_compo
|
|||
complete -f -c composer -n '__fish_composer_using_command why-not' -a "(__fish_composer_installed_packages)"
|
||||
complete -f -c composer -n '__fish_composer_using_command depends' -a "(__fish_composer_installed_packages)"
|
||||
|
||||
# Custom scripts
|
||||
complete -f -c composer -n '__fish_composer_needs_command' -a '(__fish_composer_scripts)' -d 'User script'
|
||||
complete -f -c composer -n '__fish_composer_using_command run-script' -a "(__fish_composer_scripts)"
|
||||
|
||||
#popisky
|
||||
complete -f -c composer -n '__fish_composer_needs_command' -a 'about' -d 'Short information about Composer'
|
||||
complete -f -c composer -n '__fish_composer_needs_command' -a 'archive' -d 'Create an archive of this composer package'
|
||||
|
|
Loading…
Reference in a new issue