|
Packit |
6f3914 |
# dnf completion -*- shell-script -*-
|
|
Packit |
6f3914 |
#
|
|
Packit |
6f3914 |
# This file is part of dnf.
|
|
Packit |
6f3914 |
#
|
|
Packit |
6f3914 |
# Copyright 2013 (C) Elad Alfassa <elad@fedoraproject.org>
|
|
Packit |
6f3914 |
# Copyright 2014-2015 (C) Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
Packit |
6f3914 |
#
|
|
Packit |
6f3914 |
# This program is free software; you can redistribute it and/or modify
|
|
Packit |
6f3914 |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
6f3914 |
# the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
6f3914 |
# (at your option) any later version.
|
|
Packit |
6f3914 |
#
|
|
Packit |
6f3914 |
# This program is distributed in the hope that it will be useful,
|
|
Packit |
6f3914 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6f3914 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
6f3914 |
# GNU General Public License for more details.
|
|
Packit |
6f3914 |
#
|
|
Packit |
6f3914 |
# You should have received a copy of the GNU General Public License
|
|
Packit |
6f3914 |
# along with this program; if not, write to the Free Software
|
|
Packit |
6f3914 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit |
6f3914 |
# 02110-1301 USA
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_main_options="
|
|
Packit |
6f3914 |
-4 -6 -b -c -C -d -e -h -q -R -v -x -y
|
|
Packit |
6f3914 |
--advisory --advisories
|
|
Packit |
6f3914 |
--allowerasing --assumeno
|
|
Packit |
6f3914 |
--assumeyes
|
|
Packit |
6f3914 |
--best --bugfix
|
|
Packit |
6f3914 |
--bz
|
|
Packit |
6f3914 |
--cacheonly --config
|
|
Packit |
6f3914 |
--color --cve
|
|
Packit |
6f3914 |
--debuglevel --debugsolver
|
|
Packit |
6f3914 |
--disableexcludes --disableplugin
|
|
Packit |
6f3914 |
--disableexcludepkgs --disablerepo
|
|
Packit |
6f3914 |
--downloadonly --destdir
|
|
Packit |
6f3914 |
--downloaddir
|
|
Packit |
6f3914 |
--errorlevel --enableplugin
|
|
Packit |
6f3914 |
--enablerepo --enhancement
|
|
Packit |
6f3914 |
--exclude --excludepkgs
|
|
Packit |
6f3914 |
--help --help-cmd
|
|
Packit |
6f3914 |
--installroot
|
|
Packit |
6f3914 |
--newpackage --nodocs
|
|
Packit |
6f3914 |
--nogpgcheck --noplugins
|
|
Packit |
6f3914 |
--noautoremove
|
|
Packit |
6f3914 |
--obsoletes
|
|
Packit |
6f3914 |
--quiet
|
|
Packit |
6f3914 |
--randomwait --refresh
|
|
Packit |
6f3914 |
--releasever --repofrompath
|
|
Packit |
6f3914 |
--repo --repoid
|
|
Packit |
6f3914 |
--rpmverbosity
|
|
Packit |
6f3914 |
--sec-severity --secseverity
|
|
Packit |
6f3914 |
--security --setopt
|
|
Packit |
6f3914 |
--skip-broken --showduplicates
|
|
Packit |
6f3914 |
--verbose --version
|
|
Packit |
6f3914 |
"
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_history_subcmds="info list redo rollback undo userinstalled"
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_secseverity_subcmds='Critical Important Low Moderate'
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_clean_subcmds="all dbcache expire-cache metadata packages"
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_repoquery_subcmds="
|
|
Packit |
6f3914 |
-a -f -i -l -s
|
|
Packit |
6f3914 |
--all --arch
|
|
Packit |
6f3914 |
--archlist --available
|
|
Packit |
6f3914 |
--alldeps
|
|
Packit |
6f3914 |
--conflicts
|
|
Packit |
6f3914 |
--deplist --duplicates
|
|
Packit |
6f3914 |
--exactdeps --extras
|
|
Packit |
6f3914 |
--envra --enhances
|
|
Packit |
6f3914 |
--file
|
|
Packit |
6f3914 |
--groupmember
|
|
Packit |
6f3914 |
--installed --installonly
|
|
Packit |
6f3914 |
--info
|
|
Packit |
6f3914 |
--latest-limit --list
|
|
Packit |
6f3914 |
--location
|
|
Packit |
6f3914 |
--nevra --nvr
|
|
Packit |
6f3914 |
--provides
|
|
Packit |
6f3914 |
--qf --queryformat
|
|
Packit |
6f3914 |
--querytags
|
|
Packit |
6f3914 |
--recent --requires-pre
|
|
Packit |
6f3914 |
--recommends --requires
|
|
Packit |
6f3914 |
--recursive --resolve
|
|
Packit |
6f3914 |
--source --suggests
|
|
Packit |
6f3914 |
--supplements --show-duplicates
|
|
Packit |
6f3914 |
--srpm
|
|
Packit |
6f3914 |
--tree
|
|
Packit |
6f3914 |
--upgrades --unneeded
|
|
Packit |
6f3914 |
--unsatisfied --userinstalled
|
|
Packit |
6f3914 |
--whatconflicts --whatobsoletes
|
|
Packit |
6f3914 |
--whatprovides --whatrequires
|
|
Packit |
6f3914 |
--whatrecommends --whatenhances
|
|
Packit |
6f3914 |
--whatsuggests --whatsupplements
|
|
Packit |
6f3914 |
"
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_repopkgs_subcmds="
|
|
Packit |
6f3914 |
check-update
|
|
Packit |
6f3914 |
info install
|
|
Packit |
6f3914 |
list
|
|
Packit |
6f3914 |
move-to
|
|
Packit |
6f3914 |
remove-or-reinstall remove-or-distro-sync
|
|
Packit |
6f3914 |
reinstall reinstall-old
|
|
Packit |
6f3914 |
upgrade upgrade-to
|
|
Packit |
6f3914 |
"
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
__dnf_python_exec=
|
|
Packit |
6f3914 |
_dnf_set_python_exec()
|
|
Packit |
6f3914 |
{
|
|
Packit |
6f3914 |
if [[ "$( readlink /usr/bin/dnf )" == "dnf-2" ]]; then
|
|
Packit |
6f3914 |
__dnf_python_exec="/usr/bin/python2"
|
|
Packit |
6f3914 |
else
|
|
Packit |
6f3914 |
if [ -x /usr/libexec/system-python ]; then
|
|
Packit |
6f3914 |
__dnf_python_exec="/usr/libexec/system-python"
|
|
Packit |
6f3914 |
else
|
|
Packit |
6f3914 |
__dnf_python_exec="/usr/bin/python3"
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
}
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
_dnf_commands_helper()
|
|
Packit |
6f3914 |
{
|
|
Packit |
6f3914 |
local helper_cmd="import sys; from dnf.cli import completion_helper as ch; ch.main(sys.argv[1:])"
|
|
Packit |
6f3914 |
local helper_opts="-d 0 -q -C --assumeno --nogpgcheck"
|
|
Packit |
6f3914 |
echo "$( ${__dnf_python_exec} -c "$helper_cmd" "$@" $helper_opts 2>/dev/null
|
|
Packit |
6f3914 |
}
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
_dnf_is_path()
|
|
Packit |
6f3914 |
{
|
|
Packit |
6f3914 |
if [[ "$1" == \.* ]] || [[ "$1" == \/* ]] || [[ "$1" == ~* ]]; then
|
|
Packit |
6f3914 |
return 0
|
|
Packit |
6f3914 |
else
|
|
Packit |
6f3914 |
return 1
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
}
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
_dnf_show_packages()
|
|
Packit |
6f3914 |
{
|
|
Packit |
6f3914 |
local args cmd=$1
|
|
Packit |
6f3914 |
_count_args
|
|
Packit |
6f3914 |
# do not print packages if command wasnt chosen yet
|
|
Packit |
6f3914 |
# eg.: dnf inTAB
|
|
Packit |
6f3914 |
[[ "$args" -eq 1 ]] && return
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
# return when "-" follows command
|
|
Packit |
6f3914 |
# eg.: dnf up -
|
|
Packit |
6f3914 |
[[ "$cur" == -* ]] && return
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
shift
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
if ! _dnf_is_path "$cur"; then
|
|
Packit |
6f3914 |
COMPREPLY+=( $(compgen -W "$( _dnf_commands_helper $cmd "$@" "$cur" )") )
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
[[ $COMPREPLY ]] && return
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
COMPREPLY+=( $(compgen -o default -f -X "!*.@(rpm)" -- "$cur" ) )
|
|
Packit |
6f3914 |
}
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
_dnf_get_first_command()
|
|
Packit |
6f3914 |
{
|
|
Packit |
6f3914 |
local cmd i
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
for (( i=1; i < ${#COMP_WORDS[@]}; i++ )); do
|
|
Packit |
6f3914 |
if [[ "$1" == *${COMP_WORDS[i]}* ]]; then
|
|
Packit |
6f3914 |
cmd=${COMP_WORDS[i]}
|
|
Packit |
6f3914 |
break
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
done
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
echo "$cmd"
|
|
Packit |
6f3914 |
}
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
_dnf()
|
|
Packit |
6f3914 |
{
|
|
Packit |
6f3914 |
_dnf_set_python_exec
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
local complete_commands complete_options extra_options command cmd_list
|
|
Packit |
6f3914 |
local cur prev words cword split
|
|
Packit |
6f3914 |
_init_completion -s || return
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
cmd_list="$( _dnf_commands_helper "_cmds" "" )"
|
|
Packit |
6f3914 |
command="$( _dnf_get_first_command "$cmd_list" )"
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
case $prev in
|
|
Packit |
6f3914 |
--version)
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
-h|--help|--help-cmd)
|
|
Packit |
6f3914 |
[[ $cword -eq 3 ]] && return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
-d|--debuglevel|-e|--errorlevel)
|
|
Packit |
6f3914 |
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- "$cur" ) )
|
|
Packit |
6f3914 |
return
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--installroot)
|
|
Packit |
6f3914 |
_filedir -d
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--enablerepo)
|
|
Packit |
6f3914 |
COMPREPLY=( $(compgen -W "$( _dnf_commands_helper repolist disabled "$cur" )" -- "$cur") )
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--disablerepo)
|
|
Packit |
6f3914 |
COMPREPLY=( $(compgen -W "$( _dnf_commands_helper repolist enabled "$cur" )" -- "$cur") )
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--color)
|
|
Packit |
6f3914 |
COMPREPLY=( $(compgen -W "yes no true false 0 1" -- "$cur" ) )
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--destdir|--downloaddir)
|
|
Packit |
6f3914 |
_filedir -d
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--sec*severity)
|
|
Packit |
6f3914 |
COMPREPLY=( $( compgen -W "$__dnf_secseverity_subcmds" -- "$cur" ) )
|
|
Packit |
6f3914 |
return ;;
|
|
Packit |
6f3914 |
*)
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
esac
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
complete_commands=
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
case "$command" in
|
|
Packit |
6f3914 |
autoremove|autoremove-n*)
|
|
Packit |
6f3914 |
_dnf_show_packages list installed
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
check)
|
|
Packit |
6f3914 |
extra_options="--all --dependencies --duplicates --obsoleted --provides"
|
|
Packit |
6f3914 |
complete_commands="all dependencies duplicates obsoleted provides"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
check-update|check-upgrade)
|
|
Packit |
6f3914 |
_dnf_show_packages list updates
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
clean)
|
|
Packit |
6f3914 |
complete_commands="$__dnf_clean_subcmds"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
dup|dist-upgrade|dsync|distro*sync|distribution-synchronization)
|
|
Packit |
6f3914 |
_dnf_show_packages list installed
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
dg|downgrade)
|
|
Packit |
6f3914 |
_dnf_show_packages $command
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
group|groups|grouperase|groupinfo|groupinstall|grouplist|groupremove|groupupdate)
|
|
Packit |
6f3914 |
extra_options="--with-optional --hidden --installed --available"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
help)
|
|
Packit |
6f3914 |
[[ $cword -eq 3 ]] && return 0
|
|
Packit |
6f3914 |
complete_commands="$cmd_list"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
history)
|
|
Packit |
6f3914 |
complete_commands="$__dnf_history_subcmds"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
info|list)
|
|
Packit |
6f3914 |
local subcmd="available installed updates upgrades
|
|
Packit |
6f3914 |
--available --installed --updates --upgrades"
|
|
Packit |
6f3914 |
case "$( _dnf_get_first_command "$subcmd" )" in
|
|
Packit |
6f3914 |
--installed|installed)
|
|
Packit |
6f3914 |
_dnf_show_packages list installed ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--available|available)
|
|
Packit |
6f3914 |
_dnf_show_packages list available ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
--updates|--upgrades|updates|upgrades)
|
|
Packit |
6f3914 |
_dnf_show_packages list updates ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
*)
|
|
Packit |
6f3914 |
_dnf_show_packages list
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
esac
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
extra_options="--all --available --installed --extras --updates
|
|
Packit |
6f3914 |
--upgrades --autoremove --recent"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
info-*|list-*|updateinfo|summary-updateinfo)
|
|
Packit |
6f3914 |
extra_options="--summary --list --info"
|
|
Packit |
6f3914 |
complete_commands="summary list info"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
in|install*|localinstall)
|
|
Packit |
6f3914 |
_dnf_show_packages $command
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
mark)
|
|
Packit |
6f3914 |
_dnf_show_packages list installed
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
mc|ref|makecache|refresh)
|
|
Packit |
6f3914 |
[[ "$prev" == *"timer" ]] && return
|
|
Packit |
6f3914 |
extra_options="--timer"
|
|
Packit |
6f3914 |
complete_commands="timer"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
provides)
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
ri|rei|reinstall)
|
|
Packit |
6f3914 |
_dnf_show_packages $command
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
rm|remove*|erase*)
|
|
Packit |
6f3914 |
_dnf_show_packages $command
|
|
Packit |
6f3914 |
extra_options="--oldinstallonly --duplicates --duplicated"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
repoinfo|repolist)
|
|
Packit |
6f3914 |
extra_options="--all --enabled --disabled"
|
|
Packit |
6f3914 |
case $prev in
|
|
Packit |
6f3914 |
enabled|--enabled)
|
|
Packit |
6f3914 |
complete_commands="$( _dnf_commands_helper $command enabled "$cur" )"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
disabled|--disabled)
|
|
Packit |
6f3914 |
complete_commands="$( _dnf_commands_helper $command disabled "$cur" )"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
all|--all|*)
|
|
Packit |
6f3914 |
complete_commands="$( _dnf_commands_helper $command all "$cur" )"
|
|
Packit |
6f3914 |
esac
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
repoquery*)
|
|
Packit |
6f3914 |
extra_options="$__dnf_repoquery_subcmds"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
repo*-pkgs|repo*-packages)
|
|
Packit |
6f3914 |
complete_commands="$__dnf_repopkgs_subcmds"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
se|search)
|
|
Packit |
6f3914 |
[[ "$prev" == *"all" ]] && return
|
|
Packit |
6f3914 |
extra_options="--all"
|
|
Packit |
6f3914 |
complete_commands="all"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
sh|shell) ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
swap) ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
um|u-m|upgrade|upgrade-n*)
|
|
Packit |
6f3914 |
_dnf_show_packages $command
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
up|up-min|update|update-n*)
|
|
Packit |
6f3914 |
_dnf_show_packages $command
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
whatprovides) ;;
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
*)
|
|
Packit |
6f3914 |
complete_commands="$cmd_list"
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
esac
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
$split && return
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
case $cur in
|
|
Packit |
6f3914 |
-*)
|
|
Packit |
6f3914 |
complete_options="$__dnf_main_options $extra_options"
|
|
Packit |
6f3914 |
COMPREPLY=( $(compgen -W "$complete_options" -- "$cur" ))
|
|
Packit |
6f3914 |
;;
|
|
Packit |
6f3914 |
*)
|
|
Packit |
6f3914 |
if [[ $cur == $command ]]; then
|
|
Packit |
6f3914 |
complete_commands="$cmd_list"
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
if [[ "$complete_commands" ]]; then
|
|
Packit |
6f3914 |
COMPREPLY=( $(compgen -W "$complete_commands" -- "$cur" ))
|
|
Packit |
6f3914 |
fi
|
|
Packit |
6f3914 |
esac
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
Packit |
6f3914 |
return 0
|
|
Packit |
6f3914 |
}
|
|
Packit |
6f3914 |
|
|
Packit |
6f3914 |
complete -F _dnf dnf dnf-2 dnf-3
|