add zsh completion

This commit is contained in:
steven-omaha
2023-02-13 22:49:09 +01:00
parent 9d5e691924
commit 53f0f4944a
2 changed files with 64 additions and 1 deletions
-1
View File
@@ -208,7 +208,6 @@ topgrade
## TODO
* add zsh completion
* add license
* in outermost Cargo.toml, add categories, keywords, readme
+64
View File
@@ -0,0 +1,64 @@
#compdef pacdef
_pacdef() {
integer ret=1
local line
function _actions {
local -a actions
actions=(
'clean:uninstall packages not managed by pacdef'
'edit:edit an imported group file'
'groups:show names of imported groups'
'import:import a new group file'
'new:create a new group file'
'remove:remove a group file'
'review:review unmanaged packages'
'search:show the group containing a package'
'show:show packages under an imported group'
'sync:install all packages from imported groups'
'unmanaged:show explicitly installed packages not managed by pacdef'
'version:show version info'
)
_describe 'action' actions
}
_arguments \
"1: :_actions" \
"*::arg:->args"
if [ -z "${XDG_CONFIG_HOME}" ]; then
GROUPDIR="~/.config/pacdef/groups"
else
GROUPDIR="${XDG_CONFIG_HOME}/pacdef/groups"
fi
case $line[1] in
edit)
_arguments "1:group file:_files -W '$GROUPDIR'"
;;
import)
_arguments "*:new group file(s):_files"
;;
new)
_arguments "*:new group file(s):"
;;
search)
_arguments "1:package:"
;;
show)
_arguments "1:group file:_files -W '$GROUPDIR'"
;;
remove)
_arguments "*:group file:_files -W '$GROUPDIR'"
;;
"") ;;
*)
_message "no more arguments"
;;
esac
return ret
}
_pacdef