#compdef apk

# apk(8) completion                                         *- shell-script -*-
# Automatically generated by apk-tools (src/genhelp_zsh.lua). Do not modify.

__apk_installed_pkgs() {
	local -a pkgs
	pkgs=(${(f)"$(apk query --summarize name --installed "${PREFIX}*" 2>/dev/null)"})
	compadd -a pkgs
}

__apk_available_pkgs() {
	local -a pkgs
	pkgs=(${(f)"$(apk query --summarize name --available "${PREFIX}*" 2>/dev/null)"})
	compadd -a pkgs
}

_apk() {
	local curcontext="$curcontext" state line
	typeset -A opt_args

	_arguments -C \
		'--allow-untrusted[Install packages with untrusted signature or no signature]' \
		'--arch[Temporarily override architectures]' \
		'--cache[When disabled, prevents using any local cache paths]' \
		'--no-cache[When disabled, prevents using any local cache paths]' \
		'--cache-dir[Temporarily override the cache directory]' \
		'--cache-max-age[Maximum AGE (in minutes) for index in cache before it'\''s refreshed]' \
		'--cache-packages[Store a copy of packages at installation time to cache]' \
		'--no-cache-packages[Store a copy of packages at installation time to cache]' \
		'--cache-predownload[Download needed packages to cache before starting to commit a transaction]' \
		'--no-cache-predownload[Download needed packages to cache before starting to commit a transaction]' \
		'--check-certificate[When disabled, omits the validation of the HTTPS server certificate]' \
		'--no-check-certificate[When disabled, omits the validation of the HTTPS server certificate]' \
		'(--force -f)'{--force,-f}'[Enable selected --force-* options (deprecated)]' \
		'--force-binary-stdout[Continue even if binary data will be printed to the terminal]' \
		'--force-broken-world[DANGEROUS\: Delete world constraints until a solution without conflicts is found]' \
		'--force-missing-repositories[Continue even if some of the repository indexes are not available]' \
		'--force-no-chroot[Disable chroot for scripts]' \
		'--force-non-repository[Continue even if packages may be lost on reboot]' \
		'--force-old-apk[Continue even if packages use unsupported features]' \
		'--force-overwrite[Overwrite files in other packages]' \
		'--force-refresh[Do not use cached files (local or from proxy)]' \
		'(--help -h)'{--help,-h}'[Print the list of all commands with descriptions]' \
		'--interactive=-[Determine if questions can be asked before performing certain operations]:auto:' \
		'--keys-dir[Override the default system trusted keys directories]' \
		'--legacy-info[Print output from "info" applet in legacy format or new "query" format]' \
		'--no-legacy-info[Print output from "info" applet in legacy format or new "query" format]' \
		'--logfile[If turned off, disables the writing of the log file]' \
		'--no-logfile[If turned off, disables the writing of the log file]' \
		'--network[If turned off, does not use the network]' \
		'--no-network[If turned off, does not use the network]' \
		'--preserve-env[Allow passing the user environment down to scripts (excluding variables starting APK_ which are reserved)]' \
		'--no-preserve-env[Allow passing the user environment down to scripts (excluding variables starting APK_ which are reserved)]' \
		'--pretty-print=-[Determine if output should be stylized to be human readable]:auto:' \
		'--preupgrade-depends[Add or modify preupgrade dependencies]' \
		'--print-arch[Print default arch and exit]' \
		'--progress=-[Enable or disable progress bar]:auto:' \
		'--progress-fd[Write progress to the specified file descriptor]' \
		'--purge[Purge modified configuration and cached packages]' \
		'--no-purge[Purge modified configuration and cached packages]' \
		'(--quiet -q)'{--quiet,-q}'[Print less information]' \
		'--repositories-file[Override system repositories, see apk-repositories(5)]' \
		'(--repository -X)'{--repository,-X}'[Specify additional package repository]' \
		'--repository-config[Specify additional package repository configuration]' \
		'(--root -p)'{--root,-p}'[Manage file system at ROOT]' \
		'--root-tmpfs=-[Specify if the ROOT is a temporary filesystem]:auto:' \
		'--sync=-[Determine if filesystem caches should be committed to disk]:auto:' \
		'--timeout[Timeout network connections if no progress is made in TIME seconds]' \
		'(--update-cache -U)'{--update-cache,-U}'[Alias for '\''--cache-max-age 0'\'']' \
		'--uvol-manager[Specify the OpenWRT UVOL volume manager executable location]' \
		'(--verbose -v)'{--verbose,-v}'[Print more information (can be specified twice)]' \
		'(--version -V)'{--version,-V}'[Print program version and exit]' \
		'--wait[Wait for TIME seconds to get an exclusive repository lock before failing]' \
		'--clean-protected[If disabled, prevents creation of .apk-new files in configuration directories]' \
		'--no-clean-protected[If disabled, prevents creation of .apk-new files in configuration directories]' \
		'--commit-hooks[If disabled, skips the pre/post hook scripts (but not other scripts)]' \
		'--no-commit-hooks[If disabled, skips the pre/post hook scripts (but not other scripts)]' \
		'--initramfs-diskless-boot[Used by initramfs when it'\''s recreating root tmpfs]' \
		'--overlay-from-stdin[Read list of overlay files from stdin]' \
		'--scripts[If disabled, prevents execution of all scripts]' \
		'--no-scripts[If disabled, prevents execution of all scripts]' \
		'--simulate[Simulate the requested operation without making any changes]' \
		'--no-simulate[Simulate the requested operation without making any changes]' \
		'-s[Simulate the requested operation without making any changes]' \
		'(--compression -c)'{--compression,-c}'[Compress the file with given ALGORITHM and LEVEL]' \
		'--sign-key[Sign the file with a private key in the specified KEYFILE]' \
		'1: :->applet' \
		'*::arg:->args'

	case $state in
		applet)
			local -a applets
			applets=(
				'adbdump:Dump v3 files in textual representation'
				'adbgen:Generate v3 files from text representation'
				'adbsign:Sign, resign or recompress v3 packages and indexes'
				'add:Add or modify constraints in WORLD and commit changes'
				'audit:Audit system for changes'
				'cache:Manage the local package cache'
				'convdb:Convert v2 installed database to v3 format'
				'convndx:Convert v2 indexes to v3 format'
				'del:Remove constraints from WORLD and commit changes'
				'dot:Render dependencies as graphviz graphs'
				'extract:Extract package file contents'
				'fetch:Download packages from repositories to a local directory'
				'fix:Fix, reinstall or upgrade packages without modifying WORLD'
				'index:Create repository index (v2) file from packages'
				'info:Give detailed information about packages or repositories'
				'list:List packages matching a pattern or other criteria'
				'manifest:Show checksums of package contents'
				'mkndx:Create repository index (v3) file from packages'
				'mkpkg:Create package (v3)'
				'policy:Show repository policy for packages'
				'query:Query information about packages by various criteria'
				'search:Search for packages by name or description'
				'stats:Show statistics about repositories and installations'
				'update:Update repository indexes'
				'upgrade:Install upgrades available from repositories'
				'verify:Verify package integrity and signature'
				'version:Compare package versions or perform tests on version strings'
			)
			_describe -t applets 'apk command' applets
			;;
		args)
			case $line[1] in
				adbdump)
					_arguments \
						'--format[Specify the output format (options\: json, yaml)]' \
						'*:arg:_default'
					;;
				adbgen)
					_arguments \
						'*:arg:_default'
					;;
				adbsign)
					_arguments \
						'--reset-signatures[Remove all existing signatures]' \
						'*:arg:_default'
					;;
				add)
					_arguments \
						'--initdb[Initialize a new package database]' \
						'(--latest -l)'{--latest,-l}'[Always choose the latest package by version]' \
						'--no-chown[Deprecated alias for --usermode]' \
						'(--upgrade -u)'{--upgrade,-u}'[Upgrade PACKAGES and their dependencies]' \
						'--usermode[Create usermode database with --initdb]' \
						'(--virtual -t)'{--virtual,-t}'[Create virtual package NAME with given dependencies]' \
						'*:package:__apk_available_pkgs'
					;;
				audit)
					_arguments \
						'--backup[Audit configuration files only (default)]' \
						'--check-permissions[Check file permissions too]' \
						'--details[Enable reporting of detail records]' \
						'--full[Same as --system, but in addition reports all added directories and files]' \
						'--ignore-busybox-symlinks[Ignore symlinks whose target is the busybox binary]' \
						'--packages[Print only the packages with changed files]' \
						'--protected-paths[Use given FILE for protected paths listings]' \
						'(--recursive -r)'{--recursive,-r}'[Descend into directories and audit them as well]' \
						'--system[Audit all system files]' \
						'*:arg:_default'
					;;
				cache)
					_arguments \
						'--add-dependencies[Add the argument dependencies to WORLD dependencies when determining which packages to download]' \
						'(--available -a)'{--available,-a}'[Selected packages to be downloaded from active repositories even if it means replacing or downgrading the installed package]' \
						'--ignore-conflict[Ignore conflicts when resolving dependencies]' \
						'(--latest -l)'{--latest,-l}'[Always choose the latest package by version]' \
						'(--upgrade -u)'{--upgrade,-u}'[When caching packages which are already installed, prefer their upgrades rather than considering the requirement fulfilled by the current installation]' \
						'--simulate[Simulate the requested operation without making any changes]' \
						'--no-simulate[Simulate the requested operation without making any changes]' \
						'-s[Simulate the requested operation without making any changes]' \
						'*:arg:_default'
					;;
				convdb)
					_arguments \
						'*:arg:_default'
					;;
				convndx)
					_arguments \
						'*:arg:_default'
					;;
				del)
					_arguments \
						'(--rdepends -r)'{--rdepends,-r}'[Recursively delete all top-level reverse dependencies, too]' \
						'*:package:__apk_installed_pkgs'
					;;
				dot)
					_arguments \
						'--errors[Consider only packages with errors]' \
						'*:package:__apk_available_pkgs'
					;;
				extract)
					_arguments \
						'--destination[Extract files to PATH]' \
						'--no-chown[Do not preserve file owner]' \
						'*:arg:_default'
					;;
				fetch)
					_arguments \
						'--built-after[Only fetch packages that have buildtime more recent than TIMESPEC]' \
						'(--link -l)'{--link,-l}'[Create hard links if possible]' \
						'--pkgname-spec[Generate downloaded package names with PKGNAME_SPEC specification]' \
						'(--output -o)'{--output,-o}'[Write the downloaded file(s) to DIR]' \
						'--simulate[Simulate the requested operation without making any changes]' \
						'--no-simulate[Simulate the requested operation without making any changes]' \
						'(--stdout -s)'{--stdout,-s}'[Dump the .apk file(s) to stdout]' \
						'--url[Print the full URL for downloaded packages]' \
						'*:package:__apk_available_pkgs'
					;;
				fix)
					_arguments \
						'(--depends -d)'{--depends,-d}'[Also fix dependencies of specified packages]' \
						'--directory-permissions[Reset all directory permissions]' \
						'(--reinstall -r)'{--reinstall,-r}'[Reinstall packages (default)]' \
						'(--upgrade -u)'{--upgrade,-u}'[Upgrade name PACKAGE if an upgrade exists and does not break dependencies]' \
						'(--xattr -x)'{--xattr,-x}'[Fix packages with broken xattrs]' \
						'*:package:__apk_installed_pkgs'
					;;
				index)
					_arguments \
						'(--description -d)'{--description,-d}'[Add a description to the index]' \
						'(--index -x)'{--index,-x}'[Read an existing index from INDEX to speed up the creation of the new index by reusing data when possible]' \
						'--merge[Merge PACKAGES into the existing INDEX]' \
						'--no-warnings[Disable the warning about missing dependencies]' \
						'(--output -o)'{--output,-o}'[Output generated index to FILE]' \
						'--prune-origin[Prune packages from the existing INDEX with same origin as any of the new PACKAGES during merge]' \
						'--rewrite-arch[Set all package'\''s architecture to ARCH]' \
						'*:package:__apk_available_pkgs'
					;;
				info)
					_arguments \
						'(--all -a)'{--all,-a}'[List all information known about the package]' \
						'(--contents -L)'{--contents,-L}'[List files included in the package]' \
						'(--depends -R)'{--depends,-R}'[List the dependencies of the package]' \
						'(--description -d)'{--description,-d}'[Print the package description]' \
						'(--exists --installed -e)'{--exists,--installed,-e}'[Check package installed status]' \
						'--install-if[List the package'\''s install_if rule]' \
						'--license[Print the package SPDX license identifier]' \
						'(--provides -P)'{--provides,-P}'[List what the package provides]' \
						'(--rdepends -r)'{--rdepends,-r}'[List reverse dependencies of the package (all other packages which depend on the package)]' \
						'--replaces[List the other packages for which this package is marked as a replacement]' \
						'--rinstall-if[List other packages whose install_if rules refer to this package]' \
						'(--size -s)'{--size,-s}'[Print the package'\''s installed size]' \
						'(--triggers -t)'{--triggers,-t}'[Print active triggers for the package]' \
						'(--webpage -w)'{--webpage,-w}'[Print the URL for the package'\''s upstream webpage]' \
						'(--who-owns -W)'{--who-owns,-W}'[Print the package which owns the specified file]' \
						'*:package:__apk_available_pkgs'
					;;
				list)
					_arguments \
						'(--available -a)'{--available,-a}'[Consider only available packages]' \
						'(--depends -d)'{--depends,-d}'[List packages by dependency]' \
						'(--installed -I)'{--installed,-I}'[Consider only installed packages]' \
						'--manifest[List installed packages in format `<name> <version>`]' \
						'(--origin -o)'{--origin,-o}'[List packages by origin]' \
						'(--orphaned -O)'{--orphaned,-O}'[Consider only orphaned packages]' \
						'(--providers -P)'{--providers,-P}'[List packages by provider]' \
						'(--upgradable --upgradeable -u)'{--upgradable,--upgradeable,-u}'[Consider only upgradable packages]' \
						'*:package:__apk_available_pkgs'
					;;
				manifest)
					_arguments \
						'*:package:__apk_available_pkgs'
					;;
				mkndx)
					_arguments \
						'(--description -d)'{--description,-d}'[Add a description to the index]' \
						'--filter-spec[Filter previous index only]' \
						'--hash[Use HASH as the algorithm for apk v3 integrity]' \
						'(--index -x)'{--index,-x}'[Read an existing index from INDEX to speed up the creation of the new index by reusing data when possible]' \
						'(--output -o)'{--output,-o}'[Output generated index to FILE]' \
						'--pkgname-spec[Specify package name specification for downloading the packages]' \
						'*:package:__apk_available_pkgs'
					;;
				mkpkg)
					_arguments \
						'--compat[Produces packages compatible with given apk versions]' \
						'(--files -F)'{--files,-F}'[Specify the build root path from where the files are collected from to be included in the package]' \
						'(--info -I)'{--info,-I}'[Specify metadata for the package]' \
						'(--output -o)'{--output,-o}'[Specify the FILE as the output file name]' \
						'--rootnode[Deprecated alias to set compat version]' \
						'--no-rootnode[Deprecated alias to set compat version]' \
						'(--script -s)'{--script,-s}'[Add the specified SCRIPT with the TYPE]' \
						'--stdout[Output resulting package to stdout]' \
						'(--trigger -t)'{--trigger,-t}'[Append TRIGGER path specification to list triggers which affect when the trigger script is executed]' \
						'--xattrs[Specify if xattrs should be included in the metadata]' \
						'--no-xattrs[Specify if xattrs should be included in the metadata]' \
						'*:arg:_default'
					;;
				policy)
					_arguments \
						'*:package:__apk_available_pkgs'
					;;
				query)
					_arguments \
						'--all-matches[Select all matched packages]' \
						'--available[Filter selection to available packages]' \
						'--fields[A comma separated list of fields to include in the output]' \
						'--format[Specify output format from default, yaml or json]' \
						'--from[Search packages from\: system (all system sources), repositories (exclude installed database), installed (exclude normal repositories) or none (command-line repositories only)]' \
						'--installed[Filter selection to installed packages]' \
						'--match[A comma separated list of fields to match the query against]' \
						'--recursive[Run solver algorithm with given CONSTRAINTS to select packages]' \
						'--summarize[Produce a summary of the specified field from all matches]' \
						'--upgradable[Filter selection to upgradable packages]' \
						'--world[Include apk-world(5) dependencies in constraints]' \
						'--orphaned[Filter selection to orphaned packages]' \
						'*:package:__apk_available_pkgs'
					;;
				search)
					_arguments \
						'(--all -a)'{--all,-a}'[Print all matching package versions]' \
						'(--description -d)'{--description,-d}'[Also search for PATTERN in the package description]' \
						'(--exact -e -x)'{--exact,-e,-x}'[Match package names exactly]' \
						'--has-origin[Match by package origin]' \
						'(--origin -o)'{--origin,-o}'[Print base package name]' \
						'(--rdepends -r)'{--rdepends,-r}'[Print reverse dependencies (other packages which depend on the package)]' \
						'*:package:__apk_available_pkgs'
					;;
				stats)
					_arguments \
						'*:arg:_default'
					;;
				update)
					_arguments \
						'*:arg:_default'
					;;
				upgrade)
					_arguments \
						'(--available -a)'{--available,-a}'[Reset all packages to versions available from current repositories]' \
						'--ignore[Upgrade all other packages than the ones listed]' \
						'(--latest -l)'{--latest,-l}'[Always choose the latest package by version]' \
						'--preupgrade[If turned off, disables the preupgrade step]' \
						'--no-preupgrade[If turned off, disables the preupgrade step]' \
						'--preupgrade-only[Perform only the preupgrade]' \
						'--prune[Prune the WORLD by removing packages which are no longer available from any configured repository]' \
						'*:package:__apk_installed_pkgs'
					;;
				verify)
					_arguments \
						'*:arg:_default'
					;;
				version)
					_arguments \
						'(--all -a)'{--all,-a}'[Consider packages from all repository tags]' \
						'(--check -c)'{--check,-c}'[Check versions for validity]' \
						'(--indexes -I)'{--indexes,-I}'[Print the version and description for each repository'\''s index]' \
						'(--limit -l)'{--limit,-l}'[Limit to packages with output matching given OPERAND]' \
						'(--test -t)'{--test,-t}'[Compare two version strings]' \
						'*:arg:_default'
					;;
			esac
			;;
	esac
}

_apk "$@"

