[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 3690fb51710e977dd4963085fcc0c9a73cf1ceee

Ville Skyttä ville.skytta at iki.fi
Tue Oct 20 18:51:50 UTC 2009


The following commit has been merged in the master branch:
commit d2ce9f59bd5f36fbb121f91f0ba452670e25334c
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Tue Oct 20 21:50:21 2009 +0300

    Add bunch of cvs command option completions.

diff --git a/contrib/cvs b/contrib/cvs
index 4f9e5a6..30f1d98 100644
--- a/contrib/cvs
+++ b/contrib/cvs
@@ -38,13 +38,19 @@ _cvs_command_options()
     cvs --help $1 2>&1 | sed -ne 's/^[[:space:]]*\(-[^[:space:]=[]*\).*/\1/p'
 }
 
+_cvs_kflags()
+{
+    COMPREPLY=( $( compgen -W 'kv kvl k o b v' -- "$cur" ) )
+}
+
 _cvs()
 {
-    local cur count mode i cvsroot cvsroots pwd
+    local cur prev count mode i cvsroot cvsroots pwd
     local -a flags miss files entries changed newremoved
 
     COMPREPLY=()
     cur=`_get_cword`
+    prev=${COMP_WORDS[COMP_CWORD-1]}
 
     count=0
     for i in "${COMP_WORDS[@]}"; do
@@ -117,8 +123,6 @@ _cvs()
             up?(d?(ate)))
                 mode=update
                 ;;
-            *)
-                ;;
             esac
         elif [[ "$i" = -* ]]; then
             flags=( "${flags[@]}" $i )
@@ -128,6 +132,16 @@ _cvs()
 
     case "$mode" in
         add)
+            case "$prev" in
+                -m)
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
             if [[ "$cur" != -* ]]; then
                 set_prefix
                 if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
@@ -146,12 +160,28 @@ _cvs()
             fi
             ;;
         admin)
+            case "$prev" in
+                -a|-A|-b|-c|-e|-l|-m|-n|-N|-o|-s|-t-|-u)
+                    return 0
+                    ;;
+                -t)
+                    _filedir
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
             if [[ "$cur" = -* ]]; then
                 COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
                     -- "$cur" ) )
             fi
             ;;
         annotate)
+            [[ "$prev" == -@(r|D) ]] && return 0
+
             if [[ "$cur" = -* ]]; then
                 COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
                     -- "$cur" ) )
@@ -161,6 +191,20 @@ _cvs()
             fi
             ;;
         checkout)
+            case "$prev" in
+                -r|-D|j)
+                    return 0
+                    ;;
+                -d)
+                    _filedir -d
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
             if [[ "$cur" != -* ]]; then
                 [ -z "$cvsroot" ] && cvsroot=$CVSROOT
                 COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \
@@ -172,6 +216,16 @@ _cvs()
             fi
             ;;
         commit)
+            case "$prev" in
+                -m|-r)
+                    return 0
+                    ;;
+                -F)
+                    _filedir
+                    return 0
+                    ;;
+            esac
+
             set_prefix
 
             if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then
@@ -205,6 +259,20 @@ _cvs()
             fi
             ;;
         export)
+            case "$prev" in
+                -r|-D)
+                    return 0
+                    ;;
+                -d)
+                    _filedir -d
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
             if [[ "$cur" != -* ]]; then
                 [ -z "$cvsroot" ] && cvsroot=$CVSROOT
                 COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
@@ -239,6 +307,16 @@ _cvs()
             fi
             ;;
         import)
+            case "$prev" in
+                -I|-b|-m|-W)
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
             if [[ "$cur" != -* ]]; then
                 # starts with same algorithm as checkout
                 [ -z "$cvsroot" ] && cvsroot=$CVSROOT
@@ -257,6 +335,16 @@ _cvs()
             fi
             ;;
         update)
+            case "$prev" in
+                -r|-D|-j|-I|-W)
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
             if [[ "$cur" = -* ]]; then
                 COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
                     -- "$cur" ) )
@@ -266,8 +354,6 @@ _cvs()
             COMPREPLY=( $( compgen -W '$( _cvs_commands ) $( _cvs_options ) \
                 --help --help-commands --help-options --version' -- "$cur" ) )
             ;;
-        *)
-            ;;
     esac
 
     return 0

-- 
bash-completion



More information about the Bash-completion-commits mailing list