update completion (WIP)
This commit is contained in:
@@ -4,4 +4,6 @@
|
|||||||
- create an outer error type for main
|
- create an outer error type for main
|
||||||
- change version names (1.0.0-beta.10)
|
- change version names (1.0.0-beta.10)
|
||||||
- tutorial
|
- tutorial
|
||||||
- update completion for new subcommands
|
- update completion for new subcommands (WIP)
|
||||||
|
- outer error types:
|
||||||
|
- no group files provided (pacdef group new --edit)
|
||||||
|
|||||||
+92
-44
@@ -3,28 +3,6 @@
|
|||||||
_pacdef() {
|
_pacdef() {
|
||||||
integer ret=1
|
integer ret=1
|
||||||
local line
|
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
|
if [ -z "${XDG_CONFIG_HOME}" ]; then
|
||||||
GROUPDIR="~/.config/pacdef/groups"
|
GROUPDIR="~/.config/pacdef/groups"
|
||||||
@@ -32,29 +10,97 @@ _pacdef() {
|
|||||||
GROUPDIR="${XDG_CONFIG_HOME}/pacdef/groups"
|
GROUPDIR="${XDG_CONFIG_HOME}/pacdef/groups"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function _subcommands {
|
||||||
|
local -a subcommands
|
||||||
|
subcommands=(
|
||||||
|
'group:manage groups (alias: g)'
|
||||||
|
'package:manage packages (alias: p)'
|
||||||
|
'version:show version info (alias: v)'
|
||||||
|
)
|
||||||
|
_describe 'subcommand' subcommands
|
||||||
|
}
|
||||||
|
|
||||||
case $line[1] in
|
function _group_actions {
|
||||||
edit)
|
local -a group_actions
|
||||||
_arguments "1:group file:_files -W '$GROUPDIR'"
|
group_actions=(
|
||||||
;;
|
'edit:edit an imported group file (alias: e)'
|
||||||
import)
|
'list:show names of imported groups (alias: l)'
|
||||||
_arguments "*:new group file(s):_files"
|
'import:import a new group file (alias: i)'
|
||||||
;;
|
'new:create a new group file (alias: n)'
|
||||||
new)
|
'remove:remove a group file (alias: r)'
|
||||||
_arguments "*:new group file(s):"
|
'show:show packages under an imported group (alias: s)'
|
||||||
;;
|
)
|
||||||
search)
|
_describe 'group action' group_actions
|
||||||
_arguments "1:package:"
|
}
|
||||||
;;
|
|
||||||
show)
|
|
||||||
_arguments "1:group file:_files -W '$GROUPDIR'"
|
function _package_actions {
|
||||||
;;
|
local -a package_actions
|
||||||
remove)
|
package_actions=(
|
||||||
_arguments "*:group file:_files -W '$GROUPDIR'"
|
'clean:uninstall packages not managed by pacdef (alias: c)'
|
||||||
;;
|
'review:review unmanaged packages (alias: r)'
|
||||||
"") ;;
|
'search:show the group containing a package (alias: se)'
|
||||||
*)
|
'sync:install all packages from imported groups (alias: sy)'
|
||||||
_message "no more arguments"
|
'unmanaged:show explicitly installed packages not managed by pacdef (alias: u)'
|
||||||
|
)
|
||||||
|
_describe 'package action' package_actions
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
"1: :_subcommands" \
|
||||||
|
"*::arg:->args" \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(args)
|
||||||
|
case $line[1] in
|
||||||
|
package)
|
||||||
|
case $line[2] in
|
||||||
|
search)
|
||||||
|
_arguments \
|
||||||
|
"2:regex:" && ret=0
|
||||||
|
;;
|
||||||
|
(clean|review|sync|unmanaged|help)
|
||||||
|
_message "no more arguments" && ret=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_arguments \
|
||||||
|
"1: :_package_actions" \
|
||||||
|
"*::arg:->args" && ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
group)
|
||||||
|
case $line[2] in
|
||||||
|
list)
|
||||||
|
_message "no more arguments" && ret=0
|
||||||
|
;;
|
||||||
|
(edit|remove|show)
|
||||||
|
_arguments "*:group file:_files -W '$GROUPDIR'" && ret=0
|
||||||
|
|
||||||
|
;;
|
||||||
|
import)
|
||||||
|
_arguments "*:new group file(s):_files" && ret=0
|
||||||
|
;;
|
||||||
|
new)
|
||||||
|
_arguments \
|
||||||
|
{-e,--edit}"[edit group file after creating them]" \
|
||||||
|
"*:new group name(s):" \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
*) _arguments \
|
||||||
|
"1: :_group_actions" \
|
||||||
|
"*::arg:->args" && ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
version)
|
||||||
|
_message "no more arguments" && ret=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_message "unknown subcommand" && ret=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -62,3 +108,5 @@ _pacdef() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_pacdef
|
_pacdef
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user