Skip to content

Commit

Permalink
bash-completion: complete 'clean|groups|repolist' using help
Browse files Browse the repository at this point in the history
Reported-by: Parag Nemade <pnemade@redhat.com>
Reference: rpm-software-management#159 (comment)
  • Loading branch information
ignatenkobrain committed Sep 10, 2014
1 parent 74b7921 commit 458bb4e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions etc/bash_completion.d/dnf-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

_dnf_help_command()
{
eval "$2='$( dnf help $1 | perl -ne "next unless /^$1/; s|.*?\[(.*?)\].*|\1|g; s/\|/ /g; print; exit" )'"
}

_dnf()
{
local commandlist="$( compgen -W '$( dnf help | cut -d" " -s -f1 | sed -e "/^[A-Z]/d" -e "/:/d" )' )"
Expand Down Expand Up @@ -59,6 +64,7 @@ _dnf()

$split && return

local comp
if [[ $command ]]; then

case $command in
Expand Down Expand Up @@ -88,6 +94,33 @@ _dnf()
esac
ext=''
;;
clean)
_dnf_help_command "clean" comp
COMPREPLY=( $( compgen -W '$( echo $comp )' -- "$cur" ) )
ext=''
;;
repolist)
case $nth in
1)
_dnf_help_command "repolist" comp
COMPREPLY=( $( compgen -W '$( echo $comp )' -- "$cur" ) )
;;
*)
;;
esac
ext=''
;;
group)
case $nth in
1)
_dnf_help_command "group" comp
COMPREPLY=( $( compgen -W '$( echo $comp )' -- "$cur" ) )
;;
*)
;;
esac
ext=''
;;
*)
ext=''
;;
Expand Down

1 comment on commit 458bb4e

@akozumpl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nack, as discussed on IRC, perl dependency.

Please sign in to comment.