diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-07-22 07:20:32 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-07-23 18:02:26 +0000 |
commit | 8e69dd54b763643791f9e767f708e190afc72e6a (patch) | |
tree | 9318ea4f3319aca9d01a09a0c08b24c75bf8346f /Completion | |
parent | 73ff356d7b4cb49861a420b2465ac731f29f9f1b (diff) | |
download | zsh-8e69dd54b763643791f9e767f708e190afc72e6a.tar.gz zsh-8e69dd54b763643791f9e767f708e190afc72e6a.tar.xz zsh-8e69dd54b763643791f9e767f708e190afc72e6a.zip |
38913: _pkg-config: Complete variables for --variable.
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Unix/Command/_pkg-config | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Completion/Unix/Command/_pkg-config b/Completion/Unix/Command/_pkg-config index e44b36897..54955ebb1 100644 --- a/Completion/Unix/Command/_pkg-config +++ b/Completion/Unix/Command/_pkg-config @@ -20,7 +20,7 @@ arguments=( "--libs-only-l[print the -l part of \"--libs\"]" "--libs-only-other[output other libs]" "--list-all[list all known packages]" - "--variable=[return the value of the specified variable]:variable" + "--variable=[return the value of the specified variable]:variable:->variable" "--define-variable=[set the global value for a variable]:name value pair" "--uninstalled[return success if any \"-uninstalled\" packages are being used]" "--exists[test whether the package exists or not]" @@ -33,11 +33,23 @@ arguments=( "*: :->packages" ) -_arguments -C $arguments && ret=0 +_arguments -C -S : $arguments && ret=0 -if [[ -n $state ]] ; then - packages=( ${${(f)"$(_call_program packages pkg-config --list-all)"}%% *} ) - _wanted packages expl 'package' compadd -a - packages && ret=0 -fi +case $state in + (packages) + packages=( ${${(f)"$(_call_program packages pkg-config --list-all)"}%% *} ) + _wanted packages expl 'package' compadd -a - packages && ret=0 + ;; + + (variable) + if [[ $line[1] != '-' ]]; then + local -a variables=( ${${(f)"$(_call_program variables "pkg-config --print-variables -- ${(q)line[1]}")"}} ) + _wanted variables expl 'variable' compadd -a - variables && ret=0 + else + _message "variable" + fi + ;; + +esac return ret |