From 997ecac0f02009133aa4fc9da87d00ff3cb5680b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 4 May 2011 22:47:05 +0300 Subject: [PATCH] samba: Use _parse_help, add bunch of option completions and basic test cases. --- completions/samba | 123 ++++++++++++++++++++-------- test/completion/smbcacls.exp | 1 + test/completion/smbclient.exp | 1 + test/completion/smbcquotas.exp | 1 + test/completion/smbget.exp | 1 + test/completion/smbpasswd.exp | 1 + test/completion/smbtar.exp | 1 + test/completion/smbtree.exp | 1 + test/lib/completions/smbcacls.exp | 20 +++++ test/lib/completions/smbclient.exp | 20 +++++ test/lib/completions/smbcquotas.exp | 20 +++++ test/lib/completions/smbget.exp | 20 +++++ test/lib/completions/smbpasswd.exp | 20 +++++ test/lib/completions/smbtar.exp | 20 +++++ test/lib/completions/smbtree.exp | 20 +++++ 15 files changed, 237 insertions(+), 33 deletions(-) create mode 100644 test/completion/smbcacls.exp create mode 100644 test/completion/smbclient.exp create mode 100644 test/completion/smbcquotas.exp create mode 100644 test/completion/smbget.exp create mode 100644 test/completion/smbpasswd.exp create mode 100644 test/completion/smbtar.exp create mode 100644 test/completion/smbtree.exp create mode 100644 test/lib/completions/smbcacls.exp create mode 100644 test/lib/completions/smbclient.exp create mode 100644 test/lib/completions/smbcquotas.exp create mode 100644 test/lib/completions/smbget.exp create mode 100644 test/lib/completions/smbpasswd.exp create mode 100644 test/lib/completions/smbtar.exp create mode 100644 test/lib/completions/smbtree.exp diff --git a/completions/samba b/completions/samba index 5a6261f7..f916bce3 100644 --- a/completions/samba +++ b/completions/samba @@ -28,13 +28,25 @@ _samba_debuglevel() COMPREPLY=( $( compgen -W '{0..10}' -- "$cur" ) ) } +_samba_sockopts() +{ + COMPREPLY=( $( compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST + TCP_NODELAY IPTOS_LOWDELAY IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF + SO_SNDLOWAT SO_RCVLOWAT' -- "$cur" ) ) +} + +_samba_signing() +{ + COMPREPLY=( $( compgen -W 'on off required' -- "$cur" ) ) +} + _smbclient() { local cur prev words cword split _init_completion -s || return case $prev in - -R) + -R|--name-resolve) _samba_resolve_order return 0; ;; @@ -43,19 +55,16 @@ _smbclient() -- "$cur" ) ) return 0; ;; - -s|-A|--authentication-file) + -s|--configfile|-A|--authentication-file) _filedir return 0; ;; - -l|--log-basename|-D) + -l|--log-basename|-D|--directory) _filedir -d return 0; ;; - -O) - COMPREPLY=( $( compgen -W 'SO_KEEPALIVE SO_REUSEADDR \ - SO_BROADCAST TCP_NODELAY IPTOS_LOWDELAY \ - IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF \ - SO_SNDLOWAT SO_RCVLOWAT' -- "$cur" ) ) + -O|--socket-options) + _samba_sockopts return 0; ;; -T) @@ -70,7 +79,16 @@ _smbclient() _samba_debuglevel return 0 ;; - -p|--port|-M|-I|-b|-U|--user|-n|-i|-T|-c) + -L|--list) + _samba_hosts + return 0 + ;; + -S|--signing) + _samba_signing + return 0 + ;; + -p|--port|-M|--message|-I|--ip-address|-b|--send-buffer|-U|--user|-n|\ + --netbiosname|-i|--scope|-T|--tar|-c|--command|-m|--max-protocol) # argument required but no completions available return 0 ;; @@ -83,9 +101,8 @@ _smbclient() $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-b -d -L -U -I -M -m -A -N -i -O \ - -p -R -s -k -P -c -D -W -l -E --debuglevel \ - --log-basename --workgroup' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _smbclient smbclient @@ -96,7 +113,7 @@ _smbget() _init_completion -s || return case $prev in - -o|-f|--outputfile|--rcfile) + -o|--outputfile|-f|--rcfile) _filedir return 0; ;; @@ -104,16 +121,20 @@ _smbget() _samba_debuglevel return 0 ;; + -w|--workgroup) + _samba_domains + return 0 + ;; + -u|--username|-p|--password|-b|--blocksize) + return 0 + ;; esac $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a --guest -r --resume -R --recursive -u \ - --username -p --password -w --workgroup -n --nonprompt -d \ - --debuglevel -D --dots -P --keep-permissions -o --outputfile -f \ - --rcfile -q --quiet -v --verbose -b --blocksize -? --help --usage' \ - -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _smbget smbget @@ -124,7 +145,7 @@ _smbcacls() _init_completion -s || return case $prev in - -s) + -s|--configfile|-A|--authentication-file) _filedir return 0; ;; @@ -136,13 +157,29 @@ _smbcacls() _samba_debuglevel return 0 ;; + --signing) + _samba_signing + return 0 + ;; + -O|--socket-options) + _samba_sockopts + return 0 + ;; + -W|--workgroup) + _samba_domains + return 0 + ;; + -\?|--help|--usage|-D|--delete|-M|--modify|-a|--add|-S|--set|-C|\ + --chown|-G|--chgrp|-n|--netbiosname|-i|--scope|-U|--user) + return 0 + ;; esac $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -M -D -S -U -C -G --numeric -t \ - -h --help -V -s -d --debuglevel -l --log-basename' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _smbcacls smbcacls @@ -153,7 +190,7 @@ _smbcquotas() _init_completion -s || return case $prev in - -s|-A|--authentication-file) + -s|--configfile|-A|--authentication-file) _filedir return 0; ;; @@ -165,14 +202,20 @@ _smbcquotas() _samba_debuglevel return 0 ;; + --signing) + _samba_signing + return 0 + ;; + -\?|--help|--usage|-U|-u|--user|-S|--set) + return 0 + ;; esac $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-u -L -F -S -n -t -v -h --help -V \ - -s --debuglevel --log-basename -N -k \ - --authentication-file --user' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _smbcquotas smbcquotas @@ -199,11 +242,13 @@ _smbpasswd() _samba_debuglevel return 0 ;; + -U|-h|-w) + return 0 + ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -c -x -d -e -D -n -r -R -m -U -h \ - -s -w -W -i -L' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) fi } && complete -F _smbpasswd smbpasswd @@ -226,11 +271,17 @@ _smbtar() _samba_debuglevel return 0 ;; + -N) + _filedir + return 0 + ;; + -p|-x|-b|-d|-u) + return 0 + ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-r -i -a -v -s -p -x -X -N -b -d -l -u -t' \ - -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) fi } && complete -F _smbtar smbtar @@ -241,7 +292,7 @@ _smbtree() _init_completion -s || return case $prev in - -s|-A|--authentication-file) + -s|--configfile|-A|--authentication-file) _filedir return 0; ;; @@ -253,14 +304,20 @@ _smbtree() _samba_debuglevel return 0 ;; + -S|--signing) + _samba_signing + return 0 + ;; + -\?|--help|--usage|-U|--user) + return 0 + ;; esac $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel -l \ - --log-basename -N -k -A --authentication-file -U --user\ - -h --help' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _smbtree smbtree diff --git a/test/completion/smbcacls.exp b/test/completion/smbcacls.exp new file mode 100644 index 00000000..333a14e7 --- /dev/null +++ b/test/completion/smbcacls.exp @@ -0,0 +1 @@ +assert_source_completions smbcacls diff --git a/test/completion/smbclient.exp b/test/completion/smbclient.exp new file mode 100644 index 00000000..09b9ad33 --- /dev/null +++ b/test/completion/smbclient.exp @@ -0,0 +1 @@ +assert_source_completions smbclient diff --git a/test/completion/smbcquotas.exp b/test/completion/smbcquotas.exp new file mode 100644 index 00000000..f7c4e94a --- /dev/null +++ b/test/completion/smbcquotas.exp @@ -0,0 +1 @@ +assert_source_completions smbcquotas diff --git a/test/completion/smbget.exp b/test/completion/smbget.exp new file mode 100644 index 00000000..8f6c849e --- /dev/null +++ b/test/completion/smbget.exp @@ -0,0 +1 @@ +assert_source_completions smbget diff --git a/test/completion/smbpasswd.exp b/test/completion/smbpasswd.exp new file mode 100644 index 00000000..de2297a6 --- /dev/null +++ b/test/completion/smbpasswd.exp @@ -0,0 +1 @@ +assert_source_completions smbpasswd diff --git a/test/completion/smbtar.exp b/test/completion/smbtar.exp new file mode 100644 index 00000000..72dd9f1f --- /dev/null +++ b/test/completion/smbtar.exp @@ -0,0 +1 @@ +assert_source_completions smbtar diff --git a/test/completion/smbtree.exp b/test/completion/smbtree.exp new file mode 100644 index 00000000..713c5bab --- /dev/null +++ b/test/completion/smbtree.exp @@ -0,0 +1 @@ +assert_source_completions smbtree diff --git a/test/lib/completions/smbcacls.exp b/test/lib/completions/smbcacls.exp new file mode 100644 index 00000000..d501f825 --- /dev/null +++ b/test/lib/completions/smbcacls.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbcacls -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbclient.exp b/test/lib/completions/smbclient.exp new file mode 100644 index 00000000..0fb8e2da --- /dev/null +++ b/test/lib/completions/smbclient.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbclient -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbcquotas.exp b/test/lib/completions/smbcquotas.exp new file mode 100644 index 00000000..24be2f60 --- /dev/null +++ b/test/lib/completions/smbcquotas.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbcquotas -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbget.exp b/test/lib/completions/smbget.exp new file mode 100644 index 00000000..938cd0e5 --- /dev/null +++ b/test/lib/completions/smbget.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbget -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbpasswd.exp b/test/lib/completions/smbpasswd.exp new file mode 100644 index 00000000..b6e86bbc --- /dev/null +++ b/test/lib/completions/smbpasswd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbpasswd -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbtar.exp b/test/lib/completions/smbtar.exp new file mode 100644 index 00000000..e0d58f5f --- /dev/null +++ b/test/lib/completions/smbtar.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbtar -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbtree.exp b/test/lib/completions/smbtree.exp new file mode 100644 index 00000000..b234e443 --- /dev/null +++ b/test/lib/completions/smbtree.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbtree -" + + +sync_after_int + + +teardown