Skip to content

completions #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 55 additions & 9 deletions Completion/Debian/Command/_apt
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,21 @@ _apt-cmd () {
/$'(install|download|source|build-dep)\0'/ -'subcmd=${match%?}' \
/$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=+-" "$expl_packages[@]" avail' \# \
\( \
// '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files: :_deb_files -c' \| \
// '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files: :_deb_files' \| \
// '%(.|)/%' -'[[ $subcmd = build-dep ]]' /'[]'/ ':files: :_deb_files -D' \| \
/$'[^\0/=]#\/'/ /'[]'/ ':apt-releases:release name:_apt_releases' \| \
/$'[^\0/=]#='/ /'[]'/ ':apt-package-versions:package version:_apt_versions_of_binary_package' \| \
\) \
\) \| \
/$'((|auto)(remove|purge)|reinstall)\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'upgrade\0'/ \| \
/$'autoclean\0'/ \| \
/$'distclean\0'/ \| \
/$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
/$'full-upgrade\0'/ \| \
/$'dist-upgrade\0'/ \| \
/$'edit-sources\0'/ \| \
/"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autopurge autoremove purge'
/$'edit-sources\0'/ /$'[^\0]#\0'/ ':sourcefiles::_values 'sourcefiles' $sources ' \# \| \
/"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep satisfy remove upgrade full-upgrade dist-upgrade edit-sources autoclean distclean changelog autoremove autopurge purge'

_apt-cmd () {
local expl_action expl_packages subcmd
Expand Down Expand Up @@ -458,7 +460,12 @@ _apt-get () {
--no-download:bool \
--no-install-recommends:bool \
--ignore-hold:bool \
--with-new-pkgs:bool \
--no-upgrade:bool \
--only-upgrade:bool \
--allow-downgrades:bool \
--allow-remove-essential:bool \
--allow-change-held-packages:bool \
--force-yes:bool \
--print-uris:bool \
--purge:bool \
Expand All @@ -475,27 +482,36 @@ _apt-get () {
--arch-only:bool \
--allow-unauthenticated:bool \
--auto-remove:bool \
-S,--snapshot:_snapshotdates \
-- \
/$'update\0'/ \| \
/$'upgrade\0'/ \| \
\( \
/$'install\0'\|$'download\0'\|$'source\0'\|$'build-dep\0'/ \
/$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=" "$expl_packages[@]" avail' \# \
/$'(install|download|source|build-dep)\0'/ -'subcmd=${match%?}' \
/$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=+-" "$expl_packages[@]" avail' \# \
\( \
/$'[^\0/=]#/'/ /'[]'/ ':apt-releases:release name:_apt_releases' \| \
/$'[^\0/=]#='/ /'[]'/ ':apt-package-versions:package version:_apt_versions_of_binary_package' \
// '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files: :_deb_files' \| \
// '%(.|)/%' -'[[ $subcmd = build-dep ]]' /'[]'/ ':files: :_deb_files -D' \| \
/$'[^\0/=]#\/'/ /'[]'/ ':apt-releases:release name:_apt_releases' \| \
/$'[^\0/=]#='/ /'[]'/ ':apt-package-versions:package version:_apt_versions_of_binary_package' \| \
\) \
\) \| \
/$'(|auto)(purge|remove)\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'dist-upgrade\0'/ \| \
/$'dselect-upgrade\0'/ \| \
/$'clean\0'/ \| \
/$'clean\0'/ \| \
/$'autoclean\0'/ \| \
/$'indextargets\0'/ \| \
/$'distclean\0'/ \| \
/$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
/$'check\0'/ \| \
/$'help\0/' \| \
/$'(|un)markauto\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/"[]"/ ':argument-1::compadd "$expl_action[@]" update upgrade install remove purge dist-upgrade dselect-upgrade clean autoclean changelog check source build-dep autopurge autoremove help markauto unmarkauto download'
/$'autoremove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'autopurge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'help\0/' \| \
/"[]"/ ':argument-1::compadd "$expl_action[@]" update upgrade install reinstall remove purge dist-upgrade dselect-upgrade clean autoclean distclean changelog check source build-dep satisfy indextargets autoremove autopurge help markauto unmarkauto download'

_apt-get () {
local expl_action expl_packages
Expand Down Expand Up @@ -589,15 +605,19 @@ _apt-cdrom () {

_apt-config () {
_apt_arguments _apt-config \
--empty:bool \
--format:arbitem \
-h,--help:bool \
-v,--version:bool \
--audit:bool \
-c,--config-file:configfile \
-o,--option:arbitem \
--color:bool \
-- \
/$'shell\0'/ \
\( \
/$'[^\0]#\0'/ ':parameters:shell variable to assign:_parameters' \
/$'[^\0]#\0'/ ':values:configuration key:compadd - ${${(f)"$(apt-config dump 2>&1)"}% *}' \
/$'[^\0]#\0'/ ':values:configuration key:compadd - ${(u)${(f)"$(apt-config --empty --no-color --format='%f%n' dump 2>&1)"}%%(::|) *}' \
\) \# \| \
/$'dump\0'/ \| \
/"[]"/ ':argument-1:action:compadd shell dump'
Expand All @@ -619,6 +639,14 @@ ${${${${(M)tmp:#*release*n=*}#*n=}%%,*}:#now}
fi
}

_apt_sources () {
local sourcelist sourceparts diretc
diretc="${"${"$(apt-config shell x dir::etc)"#*\'}"%\'*}"
sourceparts="${"${"$(apt-config shell x dir::etc::sourceparts)"#*\'}"%\'*}"
print /${diretc}/$sourceparts/*.{list,sources}(N:t)
}
sources=( $(_apt_sources) )

_apt_releases () {
local update_policy

Expand Down Expand Up @@ -707,4 +735,22 @@ _apt-mark () {
_apt-mark "$@"
}

_snapshotdates() {
local expl
local -a waybackdates

getdates() {
whence -p python3 &>/dev/null || return 0
local timespan='-6month'
local timestamp="$(date +%Y%m%d --date="${timespan}")"
local url="http://snapshot.debian.org/mr/timestamp/?archive=debian&after=${timestamp}"
python3 -c 'import sys,urllib.request,json;[print(x) for x in json.loads(urllib.request.urlopen(sys.argv[1]).read())["result"]["debian"]]' "$url" 2>/dev/null || :
}
snapshotdates=(
${(u)$(getdates)%T*}
)
_wanted list expl 'wayback date(s)' compadd ${expl} -- ${snapshotdates}
}


_apt "$@"
3 changes: 2 additions & 1 deletion Completion/Debian/Command/_apt-file
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ case $state in
'update:resynchronize package contents'
{find,search}:'search in which package file is included'
{list,show}:'list contents of a package'
'list-indices:list the known content indices'
'purge:remove all Contents-<ARCH>.gz files in cache directory'
)
_describe -t commands 'apt-list command' cmds
Expand All @@ -46,7 +47,7 @@ case $state in
list|show)
_deb_packages avail
;;
update|purge)
update|purge|list-indices)
# do nothing
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion Completion/Debian/Command/_bug
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _bug_commonargs=(
)

_rb_commonargs=(
'(-B --bts)'{-B,--bts=}'[use alternate BTS]:system:(debian gnome kde tdyc kde-debian)'
'(-B --bts)'{-B,--bts=}'[use alternate BTS]:system:(debian ubuntu guug default Grml)'
'(-l --ldap)'{-l,--ldap}'[enable LDAP support]'
'(-l --ldap)--no-ldap[disable LDAP support]'
'(--proxy --http_proxy)'--{http_,}'proxy=:proxy host:_hosts'
Expand Down
3 changes: 3 additions & 0 deletions Completion/Debian/Command/_debmany
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#compdef debmany

_deb_packages avail
2 changes: 1 addition & 1 deletion Completion/Debian/Command/_debsnap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _arguments \
'(-d --destdir)'{-d+,--destdir=}'[set download directory]:download directory:_files -/' \
'(-f --force)'{-f,--force}'[allow non-empty destination directory]' \
'(-v --verbose)'{-v,--verbose}'[print configuration and report progress]' \
--list"[list versions; don't download]" \
'(-l --list)'{-l,--list}"[list versions; don't download]" \
--binary'[operate on binary packages (default: source packages)]' \
'*'{-a+,--architecture=}'[specify architectures to download]:architecture to download:_deb_architectures' \
--first='[download all versions newer than this]:version number (lower bound):->versions' \
Expand Down
13 changes: 13 additions & 0 deletions Completion/Debian/Command/_dhomepage
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#compdef dhomepage

local arguments

arguments=(
'(-v,--vcs)'{-v,--vcs}'[Open VCS-Homepage instead]'
'(-e,--echo)'{-e,--echo}'[Only print the URL]'
{-h,--help}'[Show help]'
'--version[Show version information]'
':package:_deb_packages avail'
)

_arguments -S $arguments
37 changes: 23 additions & 14 deletions Completion/Debian/Command/_dpkg
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ _dpkg_deb_only_actions=(
_dpkg_deb_actions=(
'(--build -b)'{--build,-b}'[build archive]:directory:_files -/'
'(--contents -c)'{--contents,-c}'[list contents]: :_deb_files'
'(--info -I)'{--info,-I}'[show info]: :_deb_files'
'(--field -f)'{--field,-f}'[show fields]: :_deb_files'
'(--control -e)'{--control,-e}'[extract control]: :_deb_files'
'(--extract -x)'{--extract,-x}'[extract files]: :_deb_files'
'(--vextract -X)'{--vextract,-X}'[extract and list files]: :_deb_files'
'(--raw-extract -R)'{--raw-extract,-R}'[extracts files and control]: :_deb_files'
'(--field -f)'{--field,-f}'[show fields]: :_deb_files'
'--fsys-tarfile[output fs tarfile]: :_deb_files'
'--ctrl-tarfile[output ctrl tarfile]: :_deb_files'
'(--info -I)'{--info,-I}'[show info]: :_deb_files'
)

_dpkg_common_actions=(
Expand All @@ -39,36 +41,43 @@ _dpkg_actions=(
'--configure[reconfigure specified packages]:*:package:->configure'
'(--remove -r)'{--remove,-r}'[remove package]:*:package:->remove'
'(--purge -P)'{--purge,-P}'[purge package]:*:package:->purge'
'(--verify -V)'{--verify,-V}'[verify package]:*:package:->verify'
'(--audit -C)'{--audit,-C}'[check for broken pkgs]'
'--update-avail[update available]:package file:_files'
'--merge-avail[merge available]:package file:_files'
'(--record-avail -A)'{--record-avail,-A}'[record available]:*:package files:->record_avail'
'--forget-old-unavail[forget uninstalled unavailable]'
'--clear-avail[clear available]'
'(--audit -C)'{--audit,-C}'[check for broken pkgs]'
'--get-selections[get selections]:pattern:'
'--set-selections[set selections]'
'--clear-selections[clear selections]'
'--yet-to-unpack[list uninstalled]'
'--print-architecture[print target architecture]'
'--print-installation-architecture'
'--print-foreign-architectures[print list of extra architectures]'
'--predep-package[predep package]'
'--add-architecture[add extra architecture]:architecture:->add_architecture'
'--remove-architecture[remove extra architecture]:architecture:->remove_architecture'
'--print-architecture[print target architecture]'
'--print-foreign-architectures[print list of extra architectures]'
'--assert--[assert feature]:what:(help support-predepends working-epoch long-filenames multi-conrep multi-arch versioned-provides protected-field)'
'--validate--[validate thing]:what:(pkgname trigname archname version)'
'--compare-versions[compare version numbers]:*::expression:= ->compare_versions'
)

_dpkg_options=(
'--abort-after[abort after errors]:number of errors:'
'--root=[alternative root]:root:_files -/'
'--instdir=[change inst root but not data dir]:_files -/'
'(--selected-only -O)'{--selected-only,-O}'[skip unselected packages]'
'(--skip-same-version -E)'{--skip-same-version,-E}'[skip packages with same version as installed]'
'(--refuse-downgrade -G)'{--refuse-downgrade,-G}'[skip packages with earlier version than installed]'
'(--auto-deconfigure -B)'{--auto-deconfigure,-B}'[install can break other packages]'
'--no-act[show potential actions but do not follow through]'
'-D+[debug options]:debug options:(h 1 2 3)'
'--debug=[debug options]:debug options:(help 1 2 3)'
--{force,refuse,no-force}'--[forcing options]:what:(all downgrade configure-any hold remove-reinstreq remove-protected remove-essential depends depends-version breaks conflicts confmiss confnew confold confdef confask overwrite overwrite-dir overwrite-diverted statoverride-add statoverride-remove security-mac unsafe-io script-chrootless architecture bad-version bad-path not-root bad-verify)'
'--ignore-depends=[ignore depends involving package]:package:_deb_packages avail'
--{force,refuse,no-force}'--[forcing options]:what:(all downgrade configure-any hold bad-path not-root overwrite overwrite-diverted bad-verify depends-version depends confnew confold confdef confmiss conflicts architecture overwrite-dir remove-reinstreq remove-essential help)'
'--no-act[show potential actions but do not follow through]'
'--dry-run[show potential actions but do not follow through]'
'--simulate[show potential actions but do not follow through]'
'--instdir=[change inst root but not data dir]:_files -/'
'--root=[alternative root]:root:_files -/'
'(--selected-only -O)'{--selected-only,-O}'[skip unselected packages]'
'(--skip-same-version -E)'{--skip-same-version,-E}'[skip packages with same version as installed]'
)

_dpkg_options_recursive=( '(--recursive -R)'{--recursive,-R}'[recursive]' )
Expand All @@ -82,11 +91,11 @@ _dpkg_deb_and_query_only_options=(
)

_dpkg_query_actions=(
'(--list -l)'{--list,-l}'[list packages]:*:packages:->list'
'(--status -s)'{--status,-s}'[display package status]:*:packages:->status'
'(--print-avail -p)'{--print-avail,-p}'[display available details]:packages:_deb_packages avail'
'(--listfiles -L)'{--listfiles,-L}'[list owned files]:*:packages:->listfiles'
'(--list -l)'{--list,-l}'[list packages]:*:packages:->list'
'(--search -S)'{--search,-S}'[search for file owner]:*:pattern:->search'
'(--print-avail -p)'{--print-avail,-p}'[display available details]:packages:_deb_packages avail'
'--admindir=[data directory]:directory:_files -/'
)

Expand Down Expand Up @@ -147,7 +156,7 @@ case "$state" in
- nonrecur \
'*: :_deb_files'
;;
remove|status|listfiles)
remove|status|listfiles|verify)
_call_function ret _dpkg_$state && return ret
_arguments -C -A "-*" -s "$_dpkg_options[@]" \
'*:package:_deb_packages installed'
Expand Down
3 changes: 3 additions & 0 deletions Completion/Debian/Command/_dpkg-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#compdef dpkg-info

_deb_packages avail
7 changes: 5 additions & 2 deletions Completion/Debian/Command/_madison
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
_arguments \
'(-a --architecture)'{-a,--architecture=}':arch:_sequence _deb_architectures -a "all source" -' \
'(-b --binary)'{-b,--binary-type=}':type:(deb udeb)' \
'(-c --component)'{-c,--component=}':component:_values -s , "component list" main contrib non-free' \
'(-c --component)'{-c,--component=}':component:_values -s , "component list" main contrib non-free non-free-firmware' \
'(-g --greaterorequal)'{-g,--greaterorequal} \
'(-G --greaterthan)'{-G,--greaterthan} \
'(-h --help)'{-h,--help} \
'(-s --suite)'{-s,--suite=}':suite:_values -s , "suite list" stable testing unstable oldstable oldoldstable' \
'(-r --regex)'{-r,--regex} \
'(-s --suite)'{-s,--suite=}':suite:_values -s , "suite list" oldstable stable testing unstable' \
'(-S --source-and-binary)'{-S,--source-and-binary} \
'(-u --url)'{-u,--url=}':url:_values -s , "url alias" debian new qa ubuntu udd archive ports' \
'--version' \
'(--no-conf --noconf)'{--no-conf,--noconf} \
'*:package:_deb_packages avail'

7 changes: 4 additions & 3 deletions Completion/Debian/Command/_sbuild
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ _sbuild_signing_keys() {
}

_sbuild() {

_arguments \
'(-h --help)'{-h,--help}'[show help message]' \
'(-V --version)'{-V,--version}'[show version information]' \
Expand Down Expand Up @@ -67,8 +68,8 @@ _sbuild() {
'(-j --jobs)'{-j=,--jobs=}'[jobs to run simultaneously]:number of jobs' \
'--debbuildopt=[option to dpkg-buildpackage]:option' \
'--debbuildopts=[options to dpkg-buildpackage]:options' \
'--dpkg-source-opt=[option to dpkg-source]:option' \
'--dpkg-source-opts=[options to dpkg-source]:options' \
\*'--dpkg-source-opt=[option to dpkg-source]:option' \
\*'--dpkg-source-opts=[options to dpkg-source]:options' \
'--mail-log-to=[send log to mail]:recipient:_email_addresses -c' \
'--mailfrom=[mail from]:sender:_email_addresses -c' \
'(-n --nolog)'{-n,--nolog}'[no build log file]' \
Expand Down Expand Up @@ -124,7 +125,7 @@ _sbuild() {
'--aspcud-criteria=[Optimization for aspcud]:criteria' \
'(--resolve-alternatives --no-resolve-alternatives)--resolve-alternatives[allow alternatives in Build-Depends*]' \
'(--resolve-alternatives --no-resolve-alternatives)--no-resolve-alternatives[disallow alternatives in Build-Depends*]' \
'--extra-package=[make a package or directory available to the resolver]:package:_files -g "*deb(-.)"' \
\*'--extra-package=[make a package or directory available to the resolver]:package:_files -g "*deb(-.)"' \
'--extra-repository=[add a repository to the resolver]:url' \
'--extra-repository-key=[add key to the resolver]:key:_files -g "*.asc(-.)"' \
'--build-path=[place to build the package inside chroot]:path:_files -/' \
Expand Down
10 changes: 10 additions & 0 deletions Completion/Debian/Command/_schroot
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ _arguments -S \
'(-a --all)'{-a,--all}'[select all chroots and active sessions]' \
'--all-chroots[select all chroots]' \
'--all-sessions[select all active sessions]' \
'--all-source-chroots[select all source chroots]' \
'--exclude-aliases[do not include aliases]' \
'*'{-c,--chroot=}'[use specified chroot]:chroot:->chroot' \
'(-d --directory)'{-d,--directory=}'[directory to use]:dir:_files -W / -P /' \
'(-u --user)'{-u,--user=}'[username (default current user)]:user:_users' \
'(-s --shell)'{-s,--shell=}'[shell to use as login shell]:shell:->shells' \
'(-l --list)'{-l,--list}'[list available chroots]' \
'(-i --info)'{-i,--info}'[show information about selected chroots]' \
'--location[print location of selected chroots]' \
'--config[dump configuration of selected chroots]' \
'(-p --preserve-environment)'{-p,--preserve-environment}'[preserve user environment]' \
'(-o --option)'{-o,--option}'[set option]' \
'(-q --quiet)'{-q,--quiet}'[quiet]' \
'(-v --verbose)'{-v,--verbose}'[verbose]' \
'(-V --version)'{-V,--version}'[version]' \
'--automatic-session[begin, run and end a session automatically]' \
'(-b --begin-session)'{-b,--begin-session}'[begin a session; returns a session ID]' \
'(-r --run-session)'{-r,--run-session}'[run an existing session]' \
'(-n --session-name)'{-n,--session-name}'[session name]' \
'--recover-session[recover an existing session]' \
'(-e --end-session)'{-e,--end-session}'[end an existing session]' \
'(-f --force)'{-f,--force}'[force operation]' \
Expand All @@ -33,4 +39,8 @@ case "$state" in
_wanted tag expl 'chroot' \
compadd $(schroot -l -a)
;;
(shells)
_wanted -C $context shells expl shell compadd ${(f)^"$(</etc/shells)"}(N)
return
;;
esac
Loading