mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 13:07:58 -05:00
zsh completion: use consistent case statement style
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
8db7e0c98d
commit
704ab17a6a
@ -134,32 +134,32 @@ _pacman_action_query() {
|
|||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:package file:_files -g "*.pkg.tar*"'
|
'*:package file:_files -g "*.pkg.tar*"'
|
||||||
;;
|
;;
|
||||||
query_group)
|
query_group)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:groups:_pacman_completions_installed_groups'
|
'*:groups:_pacman_completions_installed_groups'
|
||||||
;;
|
;;
|
||||||
query_owner)
|
query_owner)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:file:_files'
|
'*:file:_files'
|
||||||
;;
|
;;
|
||||||
query_search)
|
query_search)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:search text: '
|
'*:search text: '
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_actions[@]" \
|
"$_pacman_opts_query_actions[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:package:_pacman_completions_installed_packages'
|
'*:package:_pacman_completions_installed_packages'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,27 +192,27 @@ _pacman_action_sync() {
|
|||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_sync_modifiers[@]" \
|
"$_pacman_opts_sync_modifiers[@]" \
|
||||||
'*-c[Remove old packages from cache]' \
|
'*-c[Remove old packages from cache]' \
|
||||||
;;
|
;;
|
||||||
sync_group)
|
sync_group)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_sync_modifiers[@]" \
|
"$_pacman_opts_sync_modifiers[@]" \
|
||||||
'*:package group:_pacman_completions_all_groups'
|
'*:package group:_pacman_completions_all_groups'
|
||||||
;;
|
;;
|
||||||
sync_search)
|
sync_search)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_sync_modifiers[@]" \
|
"$_pacman_opts_sync_modifiers[@]" \
|
||||||
'*:search text: '
|
'*:search text: '
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_sync_actions[@]" \
|
"$_pacman_opts_sync_actions[@]" \
|
||||||
"$_pacman_opts_sync_modifiers[@]" \
|
"$_pacman_opts_sync_modifiers[@]" \
|
||||||
'*:package:_pacman_completions_all_packages'
|
'*:package:_pacman_completions_all_packages'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# handles --upgrade subcommand
|
# handles --upgrade subcommand
|
||||||
@ -328,21 +328,31 @@ _pacman_zsh_comp() {
|
|||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:groups:_pacman_completions_installed_groups'
|
'*:groups:_pacman_completions_installed_groups'
|
||||||
;;
|
;;
|
||||||
Q*o*) # file
|
Q*o*) # file
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:package file:_files'
|
'*:package file:_files'
|
||||||
;;
|
;;
|
||||||
Q*p*) # file *.pkg.tar*
|
Q*p*) # file *.pkg.tar*
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_query_modifiers[@]" \
|
"$_pacman_opts_query_modifiers[@]" \
|
||||||
'*:package file:_files -g "*.pkg.tar*"'
|
'*:package file:_files -g "*.pkg.tar*"'
|
||||||
;;
|
;;
|
||||||
Q*) _pacman_action_query ;;
|
T*)
|
||||||
R*) _pacman_action_remove ;;
|
_arguments -s : \
|
||||||
|
'-T' \
|
||||||
|
"$_pacman_opts_common[@]" \
|
||||||
|
":packages:_pacman_all_packages"
|
||||||
|
;;
|
||||||
|
Q*)
|
||||||
|
_pacman_action_query
|
||||||
|
;;
|
||||||
|
R*)
|
||||||
|
_pacman_action_remove
|
||||||
|
;;
|
||||||
S*c*) # no completion
|
S*c*) # no completion
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@ -351,23 +361,31 @@ _pacman_zsh_comp() {
|
|||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_sync_modifiers[@]" \
|
"$_pacman_opts_sync_modifiers[@]" \
|
||||||
'*:package repo:_pacman_completions_repositories' \
|
'*:package repo:_pacman_completions_repositories' \
|
||||||
;;
|
;;
|
||||||
S*g*) # pkg groups
|
S*g*) # pkg groups
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
"$_pacman_opts_sync_modifiers[@]" \
|
"$_pacman_opts_sync_modifiers[@]" \
|
||||||
'*:package group:_pacman_completions_all_groups'
|
'*:package group:_pacman_completions_all_groups'
|
||||||
;;
|
;;
|
||||||
S*) _pacman_action_sync ;;
|
S*)
|
||||||
|
_pacman_action_sync
|
||||||
|
;;
|
||||||
T*)
|
T*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
'-T' \
|
'-T' \
|
||||||
"$_pacman_opts_common[@]" \
|
"$_pacman_opts_common[@]" \
|
||||||
":packages:_pacman_all_packages"
|
":packages:_pacman_all_packages"
|
||||||
;;
|
;;
|
||||||
U*) _pacman_action_upgrade ;;
|
U*)
|
||||||
V*) _pacman_action_version ;;
|
_pacman_action_upgrade
|
||||||
* ) _pacman_action_none ;;
|
;;
|
||||||
|
V*)
|
||||||
|
_pacman_action_version
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_pacman_action_none
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +400,7 @@ _key_shortopts=(
|
|||||||
'-u[Update the trustdb of pacman]'
|
'-u[Update the trustdb of pacman]'
|
||||||
'-v[Verify the file specified by the signature]: :_files -g "*.sig"'
|
'-v[Verify the file specified by the signature]: :_files -g "*.sig"'
|
||||||
'-V[Show program version]'
|
'-V[Show program version]'
|
||||||
)
|
)
|
||||||
|
|
||||||
_key_longopts=(
|
_key_longopts=(
|
||||||
'--help[show help]'
|
'--help[show help]'
|
||||||
@ -403,48 +421,50 @@ _key_longopts=(
|
|||||||
'--lsign-key[Locally sign the specified keyid]:*: :_keys'
|
'--lsign-key[Locally sign the specified keyid]:*: :_keys'
|
||||||
'--populate[Reload the default keys from the (given) keyrings in '/usr/share/pacman/keyrings']: :_path_files -W /usr/share/pacman/keyrings'
|
'--populate[Reload the default keys from the (given) keyrings in '/usr/share/pacman/keyrings']: :_path_files -W /usr/share/pacman/keyrings'
|
||||||
'--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys'
|
'--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys'
|
||||||
)
|
)
|
||||||
|
|
||||||
_pacman_key_options=(
|
_pacman_key_options=(
|
||||||
'--config[Use an alternate config file (instead of /etc/pacman.con)]: :_files'
|
'--config[Use an alternate config file (instead of /etc/pacman.con)]: :_files'
|
||||||
'--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/'
|
'--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/'
|
||||||
'--keyserver[Specify a keyserver to use if necessary]'
|
'--keyserver[Specify a keyserver to use if necessary]'
|
||||||
)
|
)
|
||||||
|
|
||||||
_pacman_key() {
|
_pacman_key() {
|
||||||
case $words[CURRENT] in
|
case $words[CURRENT] in
|
||||||
--*)
|
--*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_key_options[@]" \
|
"$_pacman_key_options[@]" \
|
||||||
"$_key_longopts[@]"
|
"$_key_longopts[@]"
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_key_options[@]" \
|
"$_pacman_key_options[@]" \
|
||||||
"$_key_shortopts[@]" \
|
"$_key_shortopts[@]" \
|
||||||
"$_key_longopts[@]"
|
"$_key_longopts[@]"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
i=$#;
|
i=$#;
|
||||||
while [[ $words[$i] != -* ]] && [[ $words[$i] != "pacman-key" ]];do
|
while [[ $words[$i] != -* ]] && [[ $words[$i] != "pacman-key" ]];do
|
||||||
i=$(($i-1))
|
i=$(($i-1))
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
--*)
|
--*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_key_options[@]" \
|
"$_pacman_key_options[@]" \
|
||||||
"$_key_longopts[@]"
|
"$_key_longopts[@]"
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
"$_pacman_key_options[@]" \
|
"$_pacman_key_options[@]" \
|
||||||
"$_key_shortopts[@]" \
|
"$_key_shortopts[@]" \
|
||||||
"$_key_longopts[@]"
|
"$_key_longopts[@]"
|
||||||
;;
|
;;
|
||||||
*) return 1;;
|
*)
|
||||||
esac
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_keys() {
|
_keys() {
|
||||||
@ -485,7 +505,7 @@ _makepkg_shortopts=(
|
|||||||
'*-r[Remove installed dependencies after a successful build]'
|
'*-r[Remove installed dependencies after a successful build]'
|
||||||
'*-R[Repackage contents of the package without rebuilding]'
|
'*-R[Repackage contents of the package without rebuilding]'
|
||||||
'*-S[Generate a source-only tarball without downloading sources]'
|
'*-S[Generate a source-only tarball without downloading sources]'
|
||||||
)
|
)
|
||||||
|
|
||||||
_makepkg_action_none(){
|
_makepkg_action_none(){
|
||||||
_arguments \
|
_arguments \
|
||||||
@ -524,51 +544,61 @@ _makepkg_longopts=(
|
|||||||
'--noconfirm[do not ask for confirmation when resolving dependencies]'
|
'--noconfirm[do not ask for confirmation when resolving dependencies]'
|
||||||
'--asdeps[Install packages as non-explicitly installed]'
|
'--asdeps[Install packages as non-explicitly installed]'
|
||||||
'--noprogressbar[Do not show a progress bar when downloading files]'
|
'--noprogressbar[Do not show a progress bar when downloading files]'
|
||||||
)
|
)
|
||||||
_makepkg(){
|
_makepkg(){
|
||||||
case $words[CURRENT] in
|
case $words[CURRENT] in
|
||||||
-*)
|
-*)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
"$_makepkg_shortopts[@]" \
|
"$_makepkg_shortopts[@]" \
|
||||||
"$_makepkg_longopts[@]"
|
"$_makepkg_longopts[@]"
|
||||||
;;
|
;;
|
||||||
--* )
|
--* )
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
"$_makepkg_longopts[@]"
|
"$_makepkg_longopts[@]"
|
||||||
;;
|
;;
|
||||||
- )_makepkg_action_none ;;
|
- )
|
||||||
* )
|
_makepkg_action_none
|
||||||
i=$#
|
;;
|
||||||
while [[ $words[i] != -* ]] && [[ $words[$i] != "makepkg" ]];do
|
*)
|
||||||
i=$((i-1));
|
i=$#
|
||||||
done
|
while [[ $words[i] != -* ]] && [[ $words[$i] != "makepkg" ]];do
|
||||||
case $words[$i] in
|
i=$((i-1));
|
||||||
-*)
|
done
|
||||||
_arguments -s -w : \
|
case $words[$i] in
|
||||||
"$_makepkg_shortopts[@]" \
|
-*)
|
||||||
"$_makepkg_longopts[@]"
|
_arguments -s -w : \
|
||||||
;;
|
"$_makepkg_shortopts[@]" \
|
||||||
--* )
|
"$_makepkg_longopts[@]"
|
||||||
_arguments -s \
|
;;
|
||||||
"$_makepkg_longopts[@]"
|
--* )
|
||||||
;;
|
_arguments -s \
|
||||||
- )_makepkg_action_none ;;
|
"$_makepkg_longopts[@]"
|
||||||
* ) return 1 ;;
|
;;
|
||||||
esac
|
- )
|
||||||
;;
|
_makepkg_action_none
|
||||||
esac
|
;;
|
||||||
|
* )
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
_pacman_comp() {
|
_pacman_comp() {
|
||||||
case "$service" in
|
case "$service" in
|
||||||
makepkg)
|
makepkg)
|
||||||
_makepkg "$@";;
|
_makepkg "$@"
|
||||||
pacman-key)
|
;;
|
||||||
_pacman_key "$@";;
|
pacman-key)
|
||||||
pacman)
|
_pacman_key "$@"
|
||||||
_pacman_zsh_comp "$@";;
|
;;
|
||||||
*)
|
pacman)
|
||||||
_message "Error";;
|
_pacman_zsh_comp "$@"
|
||||||
esac
|
;;
|
||||||
|
*)
|
||||||
|
_message "Error"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_pacman_comp "$@"
|
_pacman_comp "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user