From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,RDNS_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: (qmail 23586 invoked from network); 25 Mar 2020 11:11:31 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from unknown (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTP; 25 Mar 2020 11:11:31 -0000 Received: (qmail 16955 invoked by alias); 25 Mar 2020 11:11:19 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45614 Received: (qmail 23297 invoked by uid 1010); 25 Mar 2020 11:11:19 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-expgw.biglobe.ne.jp by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25758. spamassassin: 3.4.2. Clear:RC:0(133.208.98.3):SA:0(-2.6/5.0):. Processed in 2.224162 secs); 25 Mar 2020 11:11:19 -0000 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf01.biglobe.ne.jp designates 133.208.98.3 as permitted sender) X-Biglobe-Sender: From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Subject: [PATCH] update _dnf Message-Id: Date: Wed, 25 Mar 2020 20:10:41 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3445.104.14) X-Biglobe-Spnum: 15769 This is a rather large update of the completion for dnf command. I tried to include (almost) all the (sub)commands and options, but I've ever used only small part of them. Basic structure of the script, i.e., _dnf for general options and _dnf_command for commands and their args/opts, is not modified. _dnf: Add missing (general) options (--color, --repo, may others). _dnf_command: Add missing completions for dnf commands (module, repoquery, repository-packages, etc.), and improve some others. _dnf_groups: New helper for 'package groups'. Cache for the groups is also added because _dnf_group can be rather slow depending on the repositories in use. (But I don't know whether there is a reliable way to validate the cache) Refactor helpers for 'repositories' and 'packages'. Add missing descriptions. Some other improvements. diff --git a/Completion/Redhat/Command/_dnf = b/Completion/Redhat/Command/_dnf index 82b9b188f..5b721edd8 100644 --- a/Completion/Redhat/Command/_dnf +++ b/Completion/Redhat/Command/_dnf @@ -1,78 +1,268 @@ #compdef dnf dnf-2 dnf-3 +# +# based on dnf-4.2.18 +# =20 _dnf_helper() { - compadd $($python_exec $helper "$@" -d 0 -q -C 2>/dev/null) + # Get the pathame of the python executable from the 1st line of = dnf-2/dnf-3. + # Probably /usr/bin/python{2,3} or /usr/libexec/platform-python. + local shebang + read -u0 shebang < $(readlink -f /usr/bin/dnf) + local python_exec=3D${${shebang##\#! #}%% *} + local -a helper_script=3D( + 'import sys' + 'from dnf.cli.completion_helper import main' + 'main(sys.argv[1:])' + ) + $python_exec -c ${(j.;.)helper_script} "$@" "$PREFIX" \ + -d 0 -q -C --assumeno --nogpgcheck 2>/dev/null = /dev/null)"}:# = *}#*\(}%\)*} ) + _store_cache dnf-groups package_groups fi + _wanted package-groups expl 'package group' compadd "$@" -a = package_groups } =20 -_dnf_local_packages() { - _files -/ -g '(#i)*.rpm(-.)' +_dnf_repoquery() { + local _h=3D'' + # 'dnf deplist' is an alias for 'dnf repoquery --deplist' + [[ $words[1] =3D deplist ]] && _h=3D'!' + local -a opts=3D( '(- *)--querytags[list tags recognized by = --queryformat]' ) + # Select options + opts+=3D( + '(-a --all)'{-a,--all}'[query all packages]' + '--arch=3D[limit results to specified architectures]:list of archs: = ' + '--available[limit results to available packages]' + '--disable-modular-filtering[include packages of inactive module = streams]' + '(-f --file)'{-f+,--file=3D}'[limit results to packages which own = specified file]:file:_files' + '--latest-limit=3D[limit results to latest packages of specified = number]:number: ' + '--recent[limit results to recently edited packages]' + '(--exactdeps)--alldeps[with --what{depends,requires}, also check = non-explicit dependencies]' + '(--alldeps)--exactdeps[with --what{depends,requires}, check only = explicit dependencies]' + '*--repo=3D[limit result to packages from the specified repo]: : = _sequence _dnf_repositories -T all' + '--srpm[operate on the corresponding source RPM]' + '--whatdepends=3D[limit result to packages that require, enhance, = recommend, suggest or supplement specified capability]:capability: ' + ) + for v in conflict enhance obsolete provide recommend require suggest = supplement; do + opts+=3D( "--what${v}s=3D[limit result to packages that $v = specified capability]:capability: " ) + done + # Query options + opts+=3D( + '--location[show a location where package could be downloaded = from]' + '--tree[display recursive tree of packages]' + $_h'--deplist[display list of all direct dependencies and their = providers]' + '--recursive[query packages recursively]' + '--resolve[resolve capabilities to originating package(s)]' + ) + # mutually exclusive Select options + opts+=3D( + + '(pkg_filter)' + '--duplicates[limit results to installed duplicate packages]' + '--installonly[limit results to installed installonly packages]' + '--unsatisfied[limit results to installed packages with unsatisfied = dependencies]' + + '(list_group)' + '--installed[limit results to installed packages]' + '--extras[limit results to extra packages (not in any repos)]' + '--upgrades[limit results to upgrades for installed packages]' + '--unneeded[limit results to packages which are no longer needed]' + '--userinstalled[limit results to packages installed by user]' + ) + # mutually exclusive Query options + opts+=3D( + + '(output_format)' + {-i,--info}'[show detailed info about the package]' + {-l,--list}'[show list of files in the packages]' + {-s,--source}'[show source RPM name]' + '--changelogs[print package changelogs]' + '--nvr[show found packages in name-version-release format]' + '--nevra[show found packages in = name-epoch:version-release.architecture format]' + '--envra[show found packages in = epoch:name-version-release.architecture format]' + {--qf=3D,--queryformat=3D}'[specify custom output format]:format: ' + '--groupmember[display groups in which the package belongs]' + + '(pkg_attr)' + '--conflicts[display capabilities that the package conflicts with]' + '--depends[display capabilities that the package depends on, = enhances, recommends, suggests or supplements]' + '--enhances[display capabilities that the package enhance]' + '--provides[display capabilities that the package provides]' + '--recommends[display capabilities that the package recommends]' + '--requires[display capabilities that the package depends on]' + '--requires-pre[display capabilities that the package depends on = for running %pre script]' + '--suggests[display capabilities that the package suggests]' + '--supplements[display capabilities that the package supplements]' + '--obsoletes[display capabilities that the package obsoletes]' + ) + _arguments : '*: : _dnf_packages -T all' $opts } =20 -_dnf() { - if [[ "$(readlink /usr/bin/dnf)" =3D=3D "dnf-2" ]]; then - local python_exec=3D"/usr/bin/python2" +_dnf_repository_packages() { + if (( CURRENT =3D=3D 2 )); then + _dnf_repositories -T all + elif (( CURRENT =3D=3D 3 )); then + local -a subcmds=3D( + 'check-update:check if updates are available in the repository' + 'info:list description of packages in the repository' + 'install:install all packages in the repository' + 'list:list packages in the repository' + 'move-to:reinstall all packages that are available in the = repository' + 'reinstall:run reinstall-old, or move-to if it fails' + 'reinstall-old:reinstall all packages that were installed from = the repository' + 'remove:remove all packages installed from the repository' + 'remove-or-distro-sync:sync packages with other repo if available = there, or remove otherwise' + 'remove-or-reinstall:reinstall packages if available in other = repo, or remove otherwise' + 'upgrade:update all packages in the repository' + ) + _describe -t subcommands 'subcommand' subcmds && ret=3D0 + elif [[ $words[3] =3D (info|list) ]]; then + if (( CURRENT =3D=3D 4 )); then + _wanted options expl "option" compadd - --all --installed = --available \ + --extras --obsoletes --recent = --upgrades + else + _dnf_packages -T all + fi + elif [[ $words[3] =3D install ]]; then + _dnf_packages -T available + elif [[ $words[3] =3D upgrade* ]]; then + _dnf_packages -T upgradable else - local python_exec=3D"/usr/bin/python3" + _dnf_packages -T installed fi - local helper=3D$(${python_exec} -c "import dnf.cli; = print('{}/completion_helper.py'.format(dnf.cli.__path__[0]))") - local cache_file=3D"/var/cache/dnf/packages.db" +} =20 - _arguments -s \ - '(- *)'{-h,--help}'[show the help message]' \ - '--version[show dnf version]' \ - '(-v --verbose)'{-v,--verbose}'[set verbose, show debug messages]' = \ - '(-q --quiet)'{-q,--quiet}'[show just the relevant content]' \ - '--allowerasing[allow erasing of installed packages]' \ - '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' = \ - '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \ - '(-c --config)'{-c,--config=3D}'[config file location]:config = file:_files' \ - '(-R --randomwait)'{-R,--randomwait=3D}'[maximum command wait time = (in minutes)]:max wait time' \ - '--releasever=3D[configure DNF for another release]:release' \ - '--refresh[set metadata as expired before running the command]' \ - '--nogpgcheck[skip checking GPG signatures on package]' \ - '--installroot=3D[set install root]:install root:_files -/' \ - '*--enablerepo=3D[enable one or more repositories]:repos to = enable:_dnf_disabled_repos' \ - '*--disablerepo=3D[disable one or more repositories]:disable = repos:_dnf_enabled_repos' \ - '*::dnf command:_dnf_command' +_dnf() { + local cache_file=3D"/var/cache/dnf/packages.db" + local -a opts=3D( + '(-6)-4[resolve to IPv4 addresses only]' + '(-4)-6[resolve to IPv6 addresses only]' + '*--advisory=3D[include packages for specified advisory]:advisory: = ' + '--allowerasing[allow erasing installed packages to resolve = dependencies]' + '(-y --assumeyes)--assumeno[answer no for all questions]' + '(-b --best)'{-b,--best}'[try the best available package version]' + '--bugfix[include bugfix relevant packages]' + '*'{--bz=3D,--bzs=3D}'[include packages needed to fix the specified = Bugzilla]:BZ ID: ' + '(-C --cacheonly)'{-C,--cacheonly}"[run entirely from system cache, = don't update cache]" + '--color=3D[control whether color is used]:when:(always never = auto)' + '--comment=3D[add comment to transaction history]:comment: ' + '(-c --config)'{-c+,--config=3D}'[specify configuration = file]:config file:_files' + '*'{--cve=3D,--cves=3D}'[include packages needed to fix the = specified CVE]:CVE ID: ' + '(-d --debuglevel)'{-d+,--debuglevel=3D}'[specify debugging output = level]:level (0-10): ' + '--debugsolver[dump detailed solving results in file ./debugdata]' + '*--disableexcludes=3D[disable config file excludes]: : = _alternative "sections\:section\:(all main)" = "repositories\:repository\:_dnf_repositories -T all"' + '(--disable --set-disabled)'{--disable,--set-disabled}'[disable = repos with config-manager command]' + '*--disableplugin=3D[disable specified plugins]:list of plugin = names: ' + '(--repo)*--disablerepo=3D[disable specified repos]: : _sequence = _dnf_repositories -T enabled' + '(--downloaddir --destdir)'{--downloaddir=3D,--destdir=3D}'[redirect = downloaded packages to the specified dir]:directory:_files -/' + '--downloadonly[only download the resolved packages]' + '(-e --errorlevel)'{-e+,--errorlevel=3D}'[specify error output = level]:level (0-10): ' + '(--enable --set-enabled)'{--enable,--set-enabled}'[enable repos = with config-manager command]' + '--enableplugin=3D[enable specified plugins]:list of plugin names: = ' + '*--enablerepo=3D[enable additional repos]: : _sequence = _dnf_repositories -T disabled' + '--enhancement[include enhancement relevant packages]' + '*'{-x+,--exclude=3D}'[exclude specified packages]: : _sequence = _dnf_packages -T all' + '--forcearch=3D[force the use of the specified arch]:arch: ' + '(-)'{-h,--help}'[show the help message]' + '--installroot=3D[set install root]:directory:_files -/' + '--newpackage[include newpackage relevant packages]' + '--noautoremove[disable removal of dependencies that are no longer = used]' + '--nobest[do not limit transactions to best candidates]' + '--nodocs[do not install documentation]' + '--nogpgcheck[skip checking GPG signatures on packages]' + '--noplugins[disable all plugins]' + '--obsoletes[enable obsoletes processing logic]' + '(-q --quiet)'{-q,--quiet}'[show just the relevant content]' + '(-R --randomwait)'{-R+,--randomwait=3D}'[maximum command wait = time]:max wait time (minutes): ' + '--refresh[set metadata as expired before running the command]' + '--releasever=3D[configure DNF for another release]:release: ' + '*--repofrompath=3D[specify additional = repos]:repository_label,path_or_url: ' + '(--disablerepo)*'{--repo=3D,--repoid=3D}'[enable just the = specified repo]: : _sequence _dnf_repositories -T all' + '--rpmverbosity=3D[set RPM debug scriptlet output level]:debug = level:(critical emergency error warn info debug)'=20 + '*--sec-severity=3D[include security relevant packages matching = specified severity]:severity:(Critical Important Moderate Low)' + '--security[include security relevant packages]' + '*--setopt=3D[override config option]:repoid.option=3Dvalue: ' + '--skip-broken[resolve depsolve problems by skipping packages]' + '--show-duplicates[show duplicate packages in repos]' + '(-v --verbose)'{-v,--verbose}'[set verbose, show debug messages]' + '(- *)--version[show dnf version]' + '(-y --assumeyes --assumeno)'{-y,--assumeyes}'[answer yes for all = questions]' + ) + _arguments -s : $opts '*::dnf command:_dnf_command' } =20 _dnf_command() { - local -a _dnf_cmds - _dnf_cmds=3D( + local -a dnf_cmds=3D( + 'alias:define and manage aliases' "autoremove:automatically remove no longer required packages" + 'check:report problems in local packagedb if any' "check-update:check for available package upgrades" "clean:remove cached data" + 'deplist:alias for "repoquery --deplist"' "distro-sync:synchronize installed packages to the latest available = versions" "downgrade:downgrade a package" - "erase:deprecated alias for remove" "group:display, or use, the groups information" "help:display a helpful usage message" "history:display, or use, the transaction history" @@ -81,117 +271,280 @@ _dnf_command() { "list:list a package or groups of packages" "makecache:generate the metadata cache" "mark:mark or unmark installed packages as installed by user" + 'module:interact with modules' "provides:find what package provides the given value" "reinstall:reinstall a package" "remove:remove a package or packages from your system" "repolist:display the configured software repositories" + 'repoquery:search repos for packages and display info about them' "repository-packages:run commands on top of all packages in given = repository" "search:search package details for the given string" - "update:deprecated alias for upgrade" + 'shell:open an interactive shell' + 'swap:replace a package by another' "updateinfo:display advisories about packages" "upgrade:upgrade a package or packages on your system" - "upgrade-to:upgrade a package on your system to the specified = version" + 'upgrade-minimal:upgrade only bugfix, enhancement or security fix' ) =20 if (( CURRENT =3D=3D 1 )); then - _describe -t commands 'dnf command' _dnf_cmds || compadd "$@" + _describe -t dnf-commands 'dnf command' dnf_cmds else - local command=3D"${${_dnf_cmds[(r)$words[1]:*]%%:*}}" - # Deal with any aliases - case $command in - erase) command=3D"remove";; - whatprovides) command=3D"provides";; - update) command=3D"upgrade";; + local curcontext=3D$curcontext cur=3D$words[CURRENT] cmd tmp expl = ret=3D1 + # Deal with aliases (not comprehensive) + case $words[1] in + check-updgrade) cmd=3Dcheck-update;; + distrosync|dsync) cmd=3Ddistro-sync;; + dg) cmd=3Ddowngrade;; + erase|rm) cmd=3Dremove;; + groups|grp) cmd=3Dgroup;; + hist) cmd=3Dhistory;; + in) cmd=3Dinstall;; + mc) cmd=3Dmakecache;; + prov|whatprovides) cmd=3Dprovides;; + rei) cmd=3Dreinstall;; + repoinfo) cmd=3Drepolist;; + rq) cmd=3Drepoquery;; + se) cmd=3Dsearch;; + sh) cmd=3Dshell;; + update|up) cmd=3Dupgrade;; + update-minimal|up-min) cmd=3Dupgrade-minimal;; + *) cmd=3D"${${dnf_cmds[(r)$words[1]:*]%%:*}}";; esac + (( $#cmd )) && curcontext=3D"${curcontext%:*:*}:dnf-${cmd}:" =20 - _is_path() { - [[ "$1" =3D=3D *\/* ]] || [[ "$1" =3D=3D \~* ]] - } - - local cur=3D$words[CURRENT] - local prev=3D"" - [[ $CURRENT > 2 ]] && prev=3D$words[$((CURRENT - 1))] - - case $command in - install|upgrade|reinstall|info|check-update|distro-sync) - if ! _is_path "$cur"; then - _dnf_available_packages "$cur" + case $cmd in + alias) + if (( CURRENT =3D=3D 2 )); then + _wanted subcommands expl 'subcommand' \ + compadd - list add delete && ret=3D0 + elif [[ $words[2] =3D add ]]; then + _message "name=3D'value'" && ret=3D0 else - _dnf_local_packages + _message "alias name" && ret=3D0 fi ;; - remove|downgrade) - if ! _is_path "$cur"; then - _dnf_installed_packages "$cur" - elif [[ "$command" =3D=3D downgrade ]]; then - _dnf_local_packages + autoremove|downgrade|reinstall) + _dnf_packages_or_rpms -T installed && ret=3D0 + ;; + check) + tmp=3D( + '--all:show all problems (default)' + '--dependencies:show dependency problems' + '--duplicates:show duplicate problems' + '--obsoleted:show obsoleted packages' + '--provides:show problems with provides' + ) + _describe -t options 'option' tmp && ret=3D0 + ;; + check-update) + if [[ $cur =3D -* ]]; then + _wanted options expl 'option' compadd - --changelogs && ret=3D0= + else + _dnf_packages -T installed && ret=3D0 fi ;; - list|clean) - _dnf_helper $command "$prev" "$cur" + clean) + tmp=3D( + 'dbcache:remove chache files generated from the repository = metadata' + 'expire-cache:mark the repository metadata expired' + 'metadata:remove the repository metadata' + 'packages:remove any cached packages' + 'all:clean all' + ) + _describe -t targets 'clean target' tmp && ret=3D0 + ;; + distro-sync) + _dnf_packages -T installed && ret=3D0 ;; group) - local -a _dnf_group_cmds - _dnf_group_cmds=3D( - "summary:display groups overview" - "info:display package lists of a group" - "install:install packages from a group" - "list:list all matching groups" - "remove:mark the group removed" - "upgrade:upgrades the group and its packages" - "mark:mark a group for installation or removal" - ) if (( CURRENT =3D=3D 2 )); then - _describe -t commands 'dnf group command' _dnf_group_cmds + tmp=3D( + "summary:display groups overview" + "info:display package lists of a group" + "install:install packages from a group" + "list:list all matching groups" + "remove:remove packages in a group not used by other = groups" + "upgrade:upgrade the group and its packages" + "mark:mark a group for installation or removal" + ) + _describe -t subcommands 'subcommand' tmp && ret=3D0 + elif (( CURRENT =3D=3D 3 )) && [[ $cur =3D -* ]]; then + if [[ $words[2] =3D=3D install ]]; then + _wanted options expl 'option' compadd - --with-optional && = ret=3D0 + elif [[ $words[2] =3D=3D list ]]; then + tmp=3D( + '--available:show only available groups' + '--installed:show only installed groups' + '--hidden:show also hidden groups' + '--ids:show also ID of groups' + ) + _describe -t options 'option' tmp && ret=3D0 + fi + elif (( CURRENT =3D=3D 3 )) && [[ $words[2] =3D=3D mark ]]; = then + _wanted subcommands expl 'subcommand' \ + compadd - install remove && ret=3D0 + else + _dnf_groups && ret=3D0 fi ;; help) if (( CURRENT =3D=3D 2 )); then - _dnf_helper '_cmds' '' + _wanted commands expl 'dnf command or alias' \ + compadd - $(_dnf_helper '_cmds') && ret=3D0 fi ;; history) - local -a _dnf_history_cmds - _dnf_history_cmds=3D( - "list:list transactions" - "info:describe the given transactions" - "redo:repeat the specified transaction" - "rollback:undo all since the given transaction" - "undo:undo transactions" - "userinstalled:list names of all packages installed by a = user" - ) if (( CURRENT =3D=3D 2 )); then - _describe -t commands 'dnf history command' _dnf_history_cmds + tmp=3D( + "list:list transactions" + "info:describe the given transactions" + "redo:repeat the specified transaction" + "rollback:undo all since the given transaction" + "undo:undo transactions" + "userinstalled:list all packages installed by users" + ) + _describe -t subcommands 'subcommand' tmp && ret=3D0 + elif [[ $words[2] !=3D userinstalled ]]; then + _message 'transaction' && ret=3D0 + fi + ;; + info|list) + if (( CURRENT =3D=3D 2 )); then + if [[ $cur =3D -* ]]; then + tmp=3D( --all --available --installed --extras + --obsoletes --upgrades --autoremove --recent ) + _wanted options expl 'option' compadd -a tmp + else + _dnf_packages -T all && ret=3D0 + fi + elif [[ $words[2] =3D=3D --(all|recent) ]]; then + _dnf_packages -T all && ret=3D0 + elif [[ $words[2] =3D=3D --available ]]; then + _dnf_packages -T available && ret=3D0 + elif [[ $words[2] =3D=3D --upgrades ]]; then + _dnf_packages -T upgradable && ret=3D0 else - _dnf_helper $command "$prev" "$cur" + _dnf_packages -T installed && ret=3D0 fi ;; + install) + _dnf_packages_or_rpms -T available && ret=3D0 + ;; makecache) if (( CURRENT =3D=3D 2 )); then - _values 'make cache' 'timer' + _describe -t options 'option' \ + '(--timer:"be more resource-aware")' && ret=3D0 fi ;; mark) if (( CURRENT =3D=3D 2 )); then - _values 'mark' 'install' 'remove' + _wanted subcommands expl 'mark as' \ + compadd - install remove group && ret=3D0 + else + _dnf_packages -T installed && ret=3D0 + fi + ;; + module) + if (( CURRENT =3D=3D 2 )); then + tmp=3D( + 'install:install a module profile including its packages' + 'update:update packages associated with an active module = stream' + 'remove:remove installed module profiles and their = packages' + 'enable:enable a module stream' + 'disable:disable a module with all its streams' + 'reset:reset module state, no longer enabled or disabled' + 'provides:list modular packages, with modules they belong = to' + 'list:list all (or selected) module streams, profiles and = states' + 'info:print detailed information about a module' + 'repoquery:list packages belonging to a module' + ) + _describe -t subcommands 'subcommand' tmp && ret=3D0 + elif (( CURRENT =3D=3D 3 )) && [[ $cur =3D -* ]]; then + if [[ $words[2] =3D remove ]]; then + tmp=3D( --all ) + elif [[ $words[2] =3D list ]]; then + tmp=3D( --all --enabled --disabled --installed ) + elif [[ $words[2] =3D info ]]; then + tmp=3D( --profile ) + elif [[ $words[2] =3D repoquery ]]; then + tmp=3D( --available --installed ) + fi + _wanted options expl 'option' compadd -a tmp && ret=3D0 else - _dnf_installed_packages "$cur" + # TODO: complete module name or spec + if [[ $words[2] =3D provides ]]; then + _dnf_packages -T all && ret=3D0 + elif [[ $words[2] =3D (disable|reset|list) ]]; then + _message 'module name' && ret=3D0 + else + _message 'module spec' && ret=3D0 + fi fi ;; provides) - _files + _files && ret=3D0 + ;; + remove) + if (( CURRENT =3D=3D 2 )) && [[ $cur =3D -* ]]; then + _wanted options expl 'option' \ + compadd - --duplicates --oldinstallonly && ret=3D0 + elif [[ $words[2] !=3D -* ]]; then + _dnf_packages_or_rpms -T installed && ret=3D0 + fi ;; repolist) if (( CURRENT =3D=3D 2 )); then - _values 'repolist' 'enabled' 'disabled' 'all' + _wanted options expl 'option' \ + compadd - --enabled --disabled --all && ret=3D0 fi ;; + repoquery|deplist) + _dnf_repoquery && ret=3D0 + ;; + repository-packages) + _dnf_repository_packages + ;; search) + if [[ $cur =3D -* ]]; then + _wanted options expl 'option' compadd - --all && ret=3D0 + else + _message 'keywords' && ret=3D0 + fi + ;; + shell) if (( CURRENT =3D=3D 2 )); then - _values 'search' 'all' + _wanted script-files expl 'script file' _files && ret=3D0 fi ;; + swap) + case $CURRENT in + 2) _dnf_packages -T installed && ret=3D0 ;; + 3) _dnf_packages -T available && ret=3D0 ;; + esac + ;; + updateinfo) + tmp=3D( + '--with-cve[print only advisories referencing CVE]' + '--with-bz[print only advisories referencing bugzilla]' + + '(output-type)' + '--summary[display just counts of advisories of each type]' + '--list[display llit of advisories]' + '--info[display detailed information of advisories]' + + '(availability)' + '--avaiable[limit to advisories about newer versions of = installed packages]' + '--installed[limit to advisories about equal or older = versions of installed packages]' + '--updates[limit to advisories about newer and available = versions of installed packages]' + ) + _arguments '*: : _dnf_packages -T installed' $tmp && ret=3D0 + ;; + upgrade) + _dnf_packages_or_rpms -T upgradable && ret=3D0 + ;; + upgrade-minimal) + _dnf_packages -T upgradable && ret=3D0 + ;; esac + return ret fi } =20