From 70fd9ca2df320a13ff51c8a7a2a3ba489d9826b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 20 Oct 2009 09:29:36 +0300 Subject: [PATCH] Add cvs --help command completion, get commands from --help-commands, offer the few long options there are rather than corresponding short ones. --- CHANGES | 2 +- contrib/cvs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 5e9d7e51..371999f0 100644 --- a/CHANGES +++ b/CHANGES @@ -15,7 +15,7 @@ bash-completion (1.x) * Apply cardctl completion to pccardctl too. * Apply pine completion to alpine too. * Remove many unnecessary short option completions where long ones exist. - * Improve gkrellm, mdadm, and mysqladmin completions. + * Improve cvs, gkrellm, mdadm, and mysqladmin completions. * Add wtf completion, based on work by Raphaƫl Droz. -- David Paleino Sun, 11 Oct 2009 11:11:57 +0200 diff --git a/contrib/cvs b/contrib/cvs index aa2d46c9..efde0269 100644 --- a/contrib/cvs +++ b/contrib/cvs @@ -23,6 +23,11 @@ get_modules() fi } +_cvs_commands() +{ + cvs --help-commands 2>&1 | awk '/^ / { print $1 }' +} + _cvs() { local cur count mode i cvsroot cvsroots pwd @@ -40,6 +45,10 @@ _cvs() fi if [ -z "$mode" ]; then case $i in + -H|--help) + COMPREPLY=( $( compgen -W "$( _cvs_commands )" -- "$cur" ) ) + return 0 + ;; -d) mode=cvsroot cvsroot=${COMP_WORDS[((count+1))]} @@ -239,14 +248,9 @@ _cvs() fi ;; "") - COMPREPLY=( $( compgen -W 'add admin annotate checkout ci co \ - commit diff delete edit export \ - freeze get history import log new \ - patch rcs rdiff release remove \ - rfreeze rlog rm rtag stat status \ - tag unedit up update -H -Q -q -b \ - -d -e -f -l -n -t -r -v -w -x -z \ - --help --version' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _cvs_commands ) \ + -Q -q -b -d -e -f -l -n -t -r -w -x -z \ + --help --help-commands --help-options --version' -- "$cur" ) ) ;; *) ;;