Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
154 changes: 138 additions & 16 deletions etc/bash_completion.d/tdnf-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ _tdnf__process_if_prev_is_option()
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--downloaddir)
--downloaddir|--download-path)
COMPREPLY=( $(compgen -d -- $cur) )
return 0
;;
--enablerepo)
opts=`tdnf repolist disabled | awk '{if (NR > 1) print $1}'`
opts=`tdnf repolist disabled 2>/dev/null | awk '{if (NR > 1) print $1}'`
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--disablerepo)
opts=`tdnf repolist enabled | awk '{if (NR > 1) print $1}'`
opts=`tdnf repolist enabled 2>/dev/null | awk '{if (NR > 1) print $1}'`
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--installroot)
-i|--installroot)
COMPREPLY=( $(compgen -d -- $cur) )
return 0
;;
--repo|repoid)
opts=`tdnf repolist all | awk '{if (NR > 1) print $1}'`
--repo|--repoid)
opts=`tdnf repolist all 2>/dev/null | awk '{if (NR > 1) print $1}'`
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
Expand All @@ -40,6 +40,61 @@ _tdnf__process_if_prev_is_option()
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--forcearch)
opts="x86_64 aarch64 noarch"
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--releasever)
COMPREPLY=( $(compgen -W "4.0 5.0" -- $cur) )
return 0
;;
--sec-severity)
opts="Critical Important Moderate Low"
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--exclude|--disableplugin|--enableplugin)
COMPREPLY=( $(compgen -W "" -- $cur) )
return 0
;;
--repofrompath|--repofromdir)
COMPREPLY=( $(compgen -d -- $cur) )
return 0
;;
--file)
COMPREPLY=( $(compgen -f -- $cur) )
return 0
;;
--arch)
opts="x86_64 aarch64 noarch"
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
;;
--metadata-path)
COMPREPLY=( $(compgen -d -- $cur) )
return 0
;;
--whatdepends|--whatrequires|--whatprovides|--whatobsoletes|--whatconflicts|--whatrecommends|--whatsuggests|--whatsupplements|--whatenhances)
COMPREPLY=( $(compgen -W "" -- $cur) )
return 0
;;
--qf)
COMPREPLY=( $(compgen -W "" -- $cur) )
return 0
;;
--to|--from)
COMPREPLY=( $(compgen -W "" -- $cur) )
return 0
;;
--setopt)
COMPREPLY=( $(compgen -W "" -- $cur) )
return 0
;;
--rpmdefine)
COMPREPLY=( $(compgen -W "" -- $cur) )
return 0
;;
esac
return 1
}
Expand All @@ -56,32 +111,99 @@ _tdnf__process_if_cmd()
return 0
;;
clean)
[ $1 -eq $(($COMP_CWORD - 1)) ] &&
if [ $1 -eq $(($COMP_CWORD - 1)) ]; then
opts="packages metadata dbcache plugins expire-cache all"
else
return 0
fi
;;
downgrade)
opts=$(tdnf list --downgrades | awk '{print $1}' | cut -d'.' -f1)
opts=$(tdnf list --downgrades 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)
;;
autoerase|autoremove|erase|reinstall|remove)
opts=$(tdnf list --installed | awk '{print $1}' | cut -d'.' -f1)
opts=$(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)
;;
history)
[ $1 -eq $(($COMP_CWORD - 1)) ] &&
if [ $1 -eq $(($COMP_CWORD - 1)) ]; then
opts="init update list rollback undo redo"
else
return 0
fi
;;
count)
return 0
;;
distro-sync)
opts=$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)
;;
install)
opts="$(tdnf list --available | awk '{print $1}' | cut -d'.' -f1) $(compgen -d -G '*.rpm')"
opts="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(compgen -d -G '*.rpm')"
;;
mark)
[ $1 -eq $(($COMP_CWORD - 1)) ] &&
if [ $1 -eq $(($COMP_CWORD - 1)) ]; then
opts="install remove"
else
return 0
fi
;;
repolist)
[ $1 -eq $(($COMP_CWORD - 1)) ] &&
if [ $1 -eq $(($COMP_CWORD - 1)) ]; then
opts="all enabled disabled"
else
return 0
fi
;;
repoquery)
# After repoquery, offer both repoquery-specific options and package names
local repoquery_opts="--available --duplicates --extras --file --installed --userinstalled --upgrades --whatconflicts --whatdepends --whatenhances --whatobsoletes --whatprovides --whatrecommends --whatrequires --whatsuggests --whatsupplements --changelogs --conflicts --depends --enhances --list --location --obsoletes --provides --qf --recommends --requires --requires-pre --suggests --supplements --source"
local pkg_names="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)"
opts="$repoquery_opts $pkg_names"
;;
update|upgrade)
opts=$(tdnf list --upgrades | awk '{print $1}' | cut -d'.' -f1)
opts=$(tdnf list --upgrades 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)
;;
check|help|makecache|nocligpgcheck)
# Commands that take no arguments
return 0
;;
check-update)
# Optional package names
opts="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)"
;;
info)
# Package names or scope options
local scope_opts="installed available updates downgrades recent all"
local pkg_names="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)"
opts="$scope_opts $pkg_names"
;;
list)
# Scope options or package names
local scope_opts="installed available updates downgrades recent all"
local pkg_names="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)"
opts="$scope_opts $pkg_names"
;;
provides|whatprovides)
# Capability names (files, provides, etc.) - no easy way to list these
# Just return 0 to allow free-form input
return 0
;;
reposync)
# Optional repository names
opts=$(tdnf repolist all 2>/dev/null | awk '{if (NR > 1) print $1}')
;;
search)
# Search terms - no easy way to list these, allow free-form input
return 0
;;
update-to|upgrade-to)
# Package names (with optional version)
opts="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)"
;;
updateinfo)
# Mode options or package names
local mode_opts="all info summary"
local pkg_names="$(tdnf list --available 2>/dev/null | awk '{print $1}' | cut -d'.' -f1) $(tdnf list --installed 2>/dev/null | awk '{print $1}' | cut -d'.' -f1)"
opts="$mode_opts $pkg_names"
;;
esac
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
Expand All @@ -92,8 +214,8 @@ _tdnf()
{
local c=0 cur __opts __cmds
COMPREPLY=()
__opts="--assumeno --assumeyes --cacheonly --debugsolver --disableexcludes --disableplugin --disablerepo --downloaddir --downloadonly --enablerepo --enableplugin --exclude --installroot --noautoremove --nogpgcheck --noplugins --quiet --reboot --refresh --releasever --repo --repofrompath --repoid --rpmverbosity --security --sec --setopt --skip --skipconflicts --skipdigest --skipsignature --skipobsoletes --testonly --version --available --duplicates --extras --file --installed --whatdepends --whatrequires --whatenhances --whatobsoletes --whatprovides --whatrecommends --whatrequires --whatsuggests --whatsupplements --depends --enhances --list --obsoletes --provides --recommends --requires --requires --suggests --source --supplements --arch --delete --download --download --gpgcheck --metadata --newest --norepopath --source --urls"
__cmds="autoerase autoremove check check-local check-update clean distro-sync downgrade erase help history info install list makecache mark provides whatprovides reinstall remove repolist repoquery reposync search update update-to updateinfo upgrade upgrade-to"
__opts="--4 -4 --6 -6 --alldeps --allowerasing --assumeno -y --assumeyes -b --best --builddeps -C --cacheonly -c --config -d --debuglevel --debugsolver --disableexcludes --disableplugin --disablerepo --downloaddir --downloadonly --enablerepo --enableplugin --exclude --forcearch --help -h -i --installroot --json --noautoremove --nodeps --nogpgcheck --noplugins -q --quiet --reboot-required --refresh --releasever --repo --repofromdir --repofrompath --repoid --rpmdefine --rpmverbosity --sec-severity --security --setopt --skip-broken --skipconflicts --skipdigest --skipsignature --skipobsoletes --source --testonly -v --verbose --version --available --duplicates --extras --file --installed --userinstalled --upgrades --whatdepends --whatrequires --whatenhances --whatobsoletes --whatprovides --whatrecommends --whatsuggests --whatsupplements --whatconflicts --changelogs --conflicts --depends --enhances --list --location --obsoletes --provides --qf --recommends --requires --requires-pre --suggests --supplements --all --info --summary --recent --updates --downgrades --to --from --reverse --arch --delete --download-metadata --download-path --gpgcheck --metadata-path --newest-only --norepopath --urls"
__cmds="autoerase autoremove check check-local check-update clean count distro-sync downgrade erase help history info install list makecache mark provides whatprovides reinstall remove repolist repoquery reposync search update update-to updateinfo upgrade upgrade-to"
cur="${COMP_WORDS[COMP_CWORD]}"
_tdnf__process_if_prev_is_option && return 0
while [ $c -lt ${COMP_CWORD} ]; do
Expand Down
Loading