[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-265-g08a4c0e

Ville Skyttä ville.skytta at iki.fi
Wed May 4 19:54:24 UTC 2011


The following commit has been merged in the master branch:
commit 174d40ecff4294655ce4dda8778ce0878033bdae
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed May 4 22:50:06 2011 +0300

    quota-tools: Use _parse_help, add bunch of option completions and basic test cases.

diff --git a/completions/quota-tools b/completions/quota-tools
index 72a67c2..e6cba91 100644
--- a/completions/quota-tools
+++ b/completions/quota-tools
@@ -8,7 +8,7 @@ _user_or_group()
 
     # complete on groups if -g was given
     for (( i=1; i < cword; i++ )); do
-        if [[ "${words[i]}" == -g ]]; then
+        if [[ "${words[i]}" == -@(g|-group) ]]; then
             COMPREPLY=( $( compgen -g -- "$cur" ) )
             return 0
         fi
@@ -18,6 +18,14 @@ _user_or_group()
     COMPREPLY=( $( compgen -u -- "$cur" ) )
 }
 
+_quota_parse_help()
+{
+    local opts=$( _parse_help "$1" )
+    [[ $opts ]] || opts=$( _parse_usage "$1" ) # non-GNU?
+    COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
+    [[ $COMPREPLY == *= ]] && compopt -o nospace
+}
+
 _quota_formats()
 {
     COMPREPLY=( $( compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur" ) )
@@ -41,15 +49,15 @@ _quota()
             _quota_formats
             return 0
             ;;
+        -h|--help|-V|--version)
+            return 0
+            ;;
     esac
 
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-F --format -g --group -u --user -v \
-            --verbose -s --human-readable -p --raw-grace -i --no-autofs -l \
-            --local-only -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q \
-            --quiet-refuse -w --no-wrap' -- "$cur" ) )
+        _quota_parse_help "$1"
     else
         _user_or_group
     fi
@@ -66,16 +74,21 @@ _setquota()
             _quota_formats
             return 0
             ;;
+        -p|--prototype)
+            _user_or_group
+            return 0
+            ;;
+        -h|--help|-V|--version)
+            return 0
+            ;;
     esac
 
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
-            -F --format -g --group -u --user -p --prototype -b --batch \
-            -c --continue-batch -t --edit-period -T --edit-times -a --all' \
-            -- "$cur" ) )
+        _quota_parse_help "$1"
     else
+        local args
         _count_args
 
         case $args in
@@ -105,14 +118,19 @@ _edquota()
             _filesystems
             return 0
             ;;
+        -p|--prototype)
+            _user_or_group
+            return 0
+            ;;
+        -h|--help|-V|--version)
+            return 0
+            ;;
     esac
 
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
-            -g --group -u --user -p --prototype -F --format -f --filesystem \
-            -t --edit-period -T --edit-times' -- "$cur" ) )
+        _quota_parse_help "$1"
     else
         _user_or_group
     fi
@@ -129,29 +147,7 @@ _quotacheck()
             _quota_formats
             return 0
             ;;
-    esac
-
-    $split && return 0
-
-    if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \
-            -g --group -u --user -c --create-files -f --force -i \
-            --interactive -n --use-first-dquot -M --try-remount -m \
-            --no-remount -R --exclude-root -F --format -a --all' -- "$cur" ) )
-    else
-        _filesystems
-    fi
-} &&
-complete -F _quotacheck -o default quotacheck
-
-_repquota()
-{
-    local cur prev words cword split
-    _init_completion -s || return
-
-    case $prev in
-        -F|--format)
-            _quota_formats
+        -h|--help|-V|--version)
             return 0
             ;;
     esac
@@ -159,15 +155,12 @@ _repquota()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \
-            -c --batch-translation -C --no-batch-translation -t \
-            --truncate-names -n --no-names -p --raw-grace -i --no-autofs \
-            -u --user -g --group -F --format' -- "$cur" ) )
+        _quota_parse_help "$1"
     else
         _filesystems
     fi
 } &&
-complete -F _repquota -o default repquota
+complete -F _quotacheck -o default quotacheck repquota
 
 _quotaon()
 {
@@ -179,46 +172,24 @@ _quotaon()
             _quota_formats
             return 0
             ;;
-    esac
-
-    $split && return 0
-
-    if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
-            -g --group -f --off -p --print-state -F --format' -- "$cur" ) )
-    else
-        _filesystems
-    fi
-} &&
-complete -F _quotaon -o default quotaon
-
-_quotaoff()
-{
-    local cur prev words cword split
-    _init_completion -s || return
-
-    case $prev in
-        -F|--format)
-            _quota_formats
-            return 0
-            ;;
         -x|--xfs-command)
             COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) )
             return 0
             ;;
+        -h|--help|-V|--version)
+            return 0
+            ;;
     esac
 
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
-            -g --group -p --print-state -x --xfs-command -F --format' \
-            -- "$cur" ) )
+        _quota_parse_help "$1"
     else
         _filesystems
     fi
 } &&
-complete -F _quotaoff -o default quotaoff
+complete -F _quotaon -o default quotaon quotaoff
 
 # Local variables:
 # mode: shell-script
diff --git a/test/completion/quota.exp b/test/completion/quota.exp
new file mode 100644
index 0000000..9c08b4f
--- /dev/null
+++ b/test/completion/quota.exp
@@ -0,0 +1 @@
+assert_source_completions quota
diff --git a/test/completion/quotacheck.exp b/test/completion/quotacheck.exp
new file mode 100644
index 0000000..5b53da8
--- /dev/null
+++ b/test/completion/quotacheck.exp
@@ -0,0 +1 @@
+assert_source_completions quotacheck
diff --git a/test/completion/quotaon.exp b/test/completion/quotaon.exp
new file mode 100644
index 0000000..e66056f
--- /dev/null
+++ b/test/completion/quotaon.exp
@@ -0,0 +1 @@
+assert_source_completions quotaon
diff --git a/test/completion/setquota.exp b/test/completion/setquota.exp
new file mode 100644
index 0000000..c97dccc
--- /dev/null
+++ b/test/completion/setquota.exp
@@ -0,0 +1 @@
+assert_source_completions setquota
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/quota.exp
similarity index 80%
copy from test/lib/completions/a2ps.exp
copy to test/lib/completions/quota.exp
index 77cd07f..1eb9f16 100644
--- a/test/lib/completions/a2ps.exp
+++ b/test/lib/completions/quota.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "a2ps "
+assert_complete_any "quota "
 
 
 sync_after_int
diff --git a/test/lib/completions/aclocal.exp b/test/lib/completions/quotacheck.exp
similarity index 77%
copy from test/lib/completions/aclocal.exp
copy to test/lib/completions/quotacheck.exp
index da133aa..4200da3 100644
--- a/test/lib/completions/aclocal.exp
+++ b/test/lib/completions/quotacheck.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "aclocal "
+assert_complete_any "quotacheck "
 
 
 sync_after_int
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/quotaon.exp
similarity index 79%
copy from test/lib/completions/a2ps.exp
copy to test/lib/completions/quotaon.exp
index 77cd07f..4acc70e 100644
--- a/test/lib/completions/a2ps.exp
+++ b/test/lib/completions/quotaon.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "a2ps "
+assert_complete_any "quotaon "
 
 
 sync_after_int
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/setquota.exp
similarity index 78%
copy from test/lib/completions/a2ps.exp
copy to test/lib/completions/setquota.exp
index 77cd07f..d169e1a 100644
--- a/test/lib/completions/a2ps.exp
+++ b/test/lib/completions/setquota.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "a2ps "
+assert_complete_any "setquota "
 
 
 sync_after_int

-- 
bash-completion



More information about the Bash-completion-commits mailing list