Commit 6f13ea12 authored by Alex Denes's avatar Alex Denes 🔧 Committed by Leo
Browse files

main/apk-tools: improve zsh completion

parent 4733e6ff
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=apk-tools
pkgver=2.12.0
pkgrel=1
pkgrel=2
pkgdesc="Alpine Package Keeper - package manager for alpine"
arch="all"
url="https://gitlab.alpinelinux.org/alpine/apk-tools"
......@@ -78,4 +78,4 @@ luaapk() {
}
sha512sums="feabd7959e6212156191b8468a10193103ea8887f921060891c5fdb6e17258cb0d80140cbcd27affd572086dcc9244bce9328ae3c352659ca7db213bf79eae6a apk-tools-v2.12.0.tar.gz
3265749409e8862beb6009488ff8726e2c9d1700a4c3827f44b6734809208a09296a151b138cf33c2bcae2217a1f825fdbe491273c2631c1ee29fd94d68cb0a2 _apk"
fa9502ad205d91694487c4731e241e970654a623262b41172ac5fbb86b6d0d1baeae105e024d2fc38eb56a3b5e0ff154f8ff36ca24fca6d65d4279cc1a20562f _apk"
......@@ -109,35 +109,40 @@ function _apk {
_describe 'subcommand' cmds
}
function _apk_subcmd_args {
local -a add_args=(
$global_opts \
local -a completion_spec=($global_opts ':subcommand:_apk_subcmds')
case ${${words:#-*}[2]} in
(add)
completion_spec+=(
$commit_opts \
$latest_opt \
$upgrade_opt \
"--initdb[Initialize a new package database]" \
"(-t --virtual)"{-t,--virtual}"[Create virtual package with given dependencies]" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local -a del_args=(
$global_opts \
;;
(del)
completion_spec+=(
$commit_opts \
"--rdepeds[Recursively delete all top-level reverse dependencies]" \
"*::installed package:_apk_installed_pkgs"
"*:installed package:_apk_installed_pkgs"
)
local -a fix_args=(
$global_opts \
;;
(fix)
completion_spec+=(
$commit_opts \
"(-d --depends)"{-d,--depends}"[Fix dependencies of specified packages]" \
"(-r --reinstall)"{-r,--reinstall}"[Reinstall packages]" \
"(-u --upgrade)"{-u,--upgrade}"[Upgrade if an upgrade is available and does not break dependencies]" \
"(-x --xattr)"{-x,--xattr}"[Fix packages with broken xattrs]" \
"--directory-permissions[Reset all directory permissions]" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local -a update_args=($global_opts $commit_opts)
local -a upgrade_args=(
$global_opts \
;;
(update) completion_spec+=($commit_opts);;
(upgrade)
completion_spec+=(
$commit_opts \
$latest_opt \
"(-a --available)"{-a,--available}"[Reset all packages to versions available from current repositories]" \
......@@ -145,16 +150,18 @@ function _apk {
"--no-self-upgrade[Do not do an early upgrade of the 'apk-tools' package]" \
"--prune[Remove packages which are no longer available from any configured repository]" \
"--self-upgrade-only[Only perform a self-upgrade of the 'apk-tools' package]" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local -a cache_args=(
$global_opts \
;;
(cache)
completion_spec+=(
$latest_opt \
$upgrade_opt \
':subcommand:_apk_cache'
'2:subcommand:_apk_cache'
)
local -a info_args=(
$global_opts \
;;
(info)
completion_spec+=(
"(-a --all)"{-a,--all}"[List all information known about the package]" \
"(-d --description)"{-d,--descripton}"[Print the package description]" \
"(-e --installed)"{-e,--installed}"[Check package installed status]" \
......@@ -169,10 +176,11 @@ function _apk {
"--license[Print the package SPDX license identifier]" \
"--replaces[List the other packages for which this package is marked as a replacement]" \
"--triggers[Print active triggers for the package]" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local -a list_args=(
$global_opts \
;;
(list)
completion_spec+=(
"(-I --installed)"{-I,--installed}"[Consider only installed packages]" \
"(-O --orphaned)"{-O,--orphaned}"[Consider only orphaned packages]" \
"(-a --available)"{-a,--available}"[Consider only available packages]" \
......@@ -180,50 +188,49 @@ function _apk {
"(-o --origin)"{-o,--origin}"[List packages by origin]" \
"(-d --depends)"{-d,--depends}"[List packages by dependency]" \
"(-P --providers)"{-P,--providers}"[List packages by provider]" \
"*::pattern"
"*:pattern"
)
local -a dot_args=(
$global_opts \
;;
(dot)
completion_spec+=(
"--errors[Consider only packages with errors]" \
"--installed[Consider only installed packages]"
)
local -a policy_args=($global_opts)
local -a index_args=(
$global_opts \
;;
(index)
completion_spec+=(
"(-d --description)"{-d,--description}"[Add a description to the index]:description" \
"(-o --output)"{-o,--output}"[Output generated index to file]:output:_files" \
"(-x --index)"{-x,--index}"[Read an existing index to speed up the creation of the new index]" \
"--no-warnings[Disable warnings about missing dependencies]" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local -a fetch_args=(
$global_opts \
;;
(fetch)
completion_spec+=(
"(-l --link)"{-l,--link}"[Create hard links if possible]" \
"(-o --output)"{-o,--output}"[Where to write the downloaded files]:directory:_dir_list" \
"(-r --recursive)"{-r,--recursive}"[Fetch packages and all of their dependencies]" \
"(-s --stdout)"{-s,--stdout}"[Dump the .apk file(s) to stdout]" \
"--simulate[Simulate the requested operation without making any changes]" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local -a manifest_args=($global_opts "*::package:_apk_packages")
local -a verify_args=($global_opts "*::package:_apk_packages")
local -a audit_args=($global_opts "*::files:_files")
local -a stats_args=($global_opts)
local -a version_args=(
$global_opts \
;;
(manifest) completion_spec+=("*:package:_apk_packages");;
(verify) completion_spec+=("*:package:_apk_packages");;
(audit) completion_spec+=("*:files:_files");;
(version)
completion_spec+=(
"-a[Consider packages from all repository tags]" \
"-l[Limit to packages with output matching given operand]:operand" \
"*::package:_apk_packages"
"*:package:_apk_packages"
)
local cmdvar="${words[1]}_args"
_arguments -s -C ${(P)cmdvar} && ret=0
}
# Main arguments
_arguments -C -s \
$global_opts \
':subcommand:_apk_subcmds' \
'*::subcommand:_apk_subcmd_args' && ret=0
;;
(policy)
completion_spec+=("*:package:_apk_packages")
;;
esac
_arguments -C -s $completion_spec && ret=0
return ret
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment