From a8be7423efb287edd5ef80002a75a853fc0c9c1d Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Mon, 12 Sep 2022 01:34:08 +0200 Subject: pkgctl: add a unified command-line frontend for devtools This is the first step of a simple and highly structured unified interface to devtools commands in a single wrapper. The split is based on groups like `repo`, `build` and `diff` Signed-off-by: Levente Polyak --- contrib/completion/zsh/_devtools.in | 42 +++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'contrib/completion') diff --git a/contrib/completion/zsh/_devtools.in b/contrib/completion/zsh/_devtools.in index d30648a..959497e 100644 --- a/contrib/completion/zsh/_devtools.in +++ b/contrib/completion/zsh/_devtools.in @@ -1,4 +1,4 @@ -#compdef archbuild pkgrepo arch-nspawn archrelease commitpkg diffpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild checkpkg sogrep offload-build makerepropkg +#compdef archbuild pkgrepo arch-nspawn archrelease commitpkg pkgctl diffpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild checkpkg sogrep offload-build makerepropkg # # SPDX-License-Identifier: GPL-3.0-or-later @@ -149,31 +149,47 @@ _devtools_completions_all_packages() { compadd - "${(@)packages}" } -_devtools() { - local service_func=_${service//-/_} - local service_cmds=${service_func}_cmds - if typeset -p ${service_cmds} &> /dev/null; then +_pkgctl_cmds=( + "pkgctl command" + "diff[Compare package files using different modes]" + "repo[Manage Git packaging repositories and their configuration]" +) + +_pkgctl_diff_args=("${_diffpkg_args[@]}") + +_pkgctl_repo_cmds=("${_pkgrepo_cmds[@]}") +_pkgctl_repo_clone_args=("${_pkgrepo_clone_args[@]}") +_pkgctl_repo_configure_args=("${_pkgrepo_configure_args[@]}") + +_handle_subcommands() { + local service_name=${1} + if typeset -p ${service_name}_cmds &> /dev/null; then _arguments -C \ "1: :->cmds" \ '*::arg:->args' case $state in cmds) - local service_cmds_array=${service_cmds}[@] - _values "${(P)service_cmds_array}" + local service_cmds=${service_name}_cmds[@] + _values "${(P)service_cmds}" ;; args) - local cmd_args_array=${service_func}_$line[1]_args - if typeset -p ${cmd_args_array} &> /dev/null; then - local cmd_args=${cmd_args_array}[@] + local service_sub=${service_name}_$line[1] + if typeset -p ${service_sub}_args &> /dev/null; then + local cmd_args=${service_sub}_args[@] _arguments -s "${(P)cmd_args}" + elif typeset -p ${service_sub}_cmds &> /dev/null; then + _handle_subcommands "${service_sub}" fi ;; esac - return 0 + elif typeset -p ${service_name}_args &> /dev/null; then + local argname="${service_name}_args[@]" + _arguments -s "${(P)argname}" fi - local argname="${service_func}_args[@]" - _arguments -s "${(P)argname}" +} +_devtools() { + _handle_subcommands _${service//-/_} } _devtools -- cgit v1.2.3-70-g09d2