samba: Use _parse_help, add bunch of option completions and basic test cases.

This commit is contained in:
Ville Skyttä 2011-05-04 22:47:05 +03:00
parent cec611fa51
commit 997ecac0f0
15 changed files with 237 additions and 33 deletions

View File

@ -28,13 +28,25 @@ _samba_debuglevel()
COMPREPLY=( $( compgen -W '{0..10}' -- "$cur" ) ) 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() _smbclient()
{ {
local cur prev words cword split local cur prev words cword split
_init_completion -s || return _init_completion -s || return
case $prev in case $prev in
-R) -R|--name-resolve)
_samba_resolve_order _samba_resolve_order
return 0; return 0;
;; ;;
@ -43,19 +55,16 @@ _smbclient()
-- "$cur" ) ) -- "$cur" ) )
return 0; return 0;
;; ;;
-s|-A|--authentication-file) -s|--configfile|-A|--authentication-file)
_filedir _filedir
return 0; return 0;
;; ;;
-l|--log-basename|-D) -l|--log-basename|-D|--directory)
_filedir -d _filedir -d
return 0; return 0;
;; ;;
-O) -O|--socket-options)
COMPREPLY=( $( compgen -W 'SO_KEEPALIVE SO_REUSEADDR \ _samba_sockopts
SO_BROADCAST TCP_NODELAY IPTOS_LOWDELAY \
IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF \
SO_SNDLOWAT SO_RCVLOWAT' -- "$cur" ) )
return 0; return 0;
;; ;;
-T) -T)
@ -70,7 +79,16 @@ _smbclient()
_samba_debuglevel _samba_debuglevel
return 0 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 # argument required but no completions available
return 0 return 0
;; ;;
@ -83,9 +101,8 @@ _smbclient()
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b -d -L -U -I -M -m -A -N -i -O \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
-p -R -s -k -P -c -D -W -l -E --debuglevel \ [[ $COMPREPLY == *= ]] && compopt -o nospace
--log-basename --workgroup' -- "$cur" ) )
fi fi
} && } &&
complete -F _smbclient smbclient complete -F _smbclient smbclient
@ -96,7 +113,7 @@ _smbget()
_init_completion -s || return _init_completion -s || return
case $prev in case $prev in
-o|-f|--outputfile|--rcfile) -o|--outputfile|-f|--rcfile)
_filedir _filedir
return 0; return 0;
;; ;;
@ -104,16 +121,20 @@ _smbget()
_samba_debuglevel _samba_debuglevel
return 0 return 0
;; ;;
-w|--workgroup)
_samba_domains
return 0
;;
-u|--username|-p|--password|-b|--blocksize)
return 0
;;
esac esac
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --guest -r --resume -R --recursive -u \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
--username -p --password -w --workgroup -n --nonprompt -d \ [[ $COMPREPLY == *= ]] && compopt -o nospace
--debuglevel -D --dots -P --keep-permissions -o --outputfile -f \
--rcfile -q --quiet -v --verbose -b --blocksize -? --help --usage' \
-- "$cur" ) )
fi fi
} && } &&
complete -F _smbget smbget complete -F _smbget smbget
@ -124,7 +145,7 @@ _smbcacls()
_init_completion -s || return _init_completion -s || return
case $prev in case $prev in
-s) -s|--configfile|-A|--authentication-file)
_filedir _filedir
return 0; return 0;
;; ;;
@ -136,13 +157,29 @@ _smbcacls()
_samba_debuglevel _samba_debuglevel
return 0 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 esac
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -M -D -S -U -C -G --numeric -t \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
-h --help -V -s -d --debuglevel -l --log-basename' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace
fi fi
} && } &&
complete -F _smbcacls smbcacls complete -F _smbcacls smbcacls
@ -153,7 +190,7 @@ _smbcquotas()
_init_completion -s || return _init_completion -s || return
case $prev in case $prev in
-s|-A|--authentication-file) -s|--configfile|-A|--authentication-file)
_filedir _filedir
return 0; return 0;
;; ;;
@ -165,14 +202,20 @@ _smbcquotas()
_samba_debuglevel _samba_debuglevel
return 0 return 0
;; ;;
--signing)
_samba_signing
return 0
;;
-\?|--help|--usage|-U|-u|--user|-S|--set)
return 0
;;
esac esac
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-u -L -F -S -n -t -v -h --help -V \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
-s --debuglevel --log-basename -N -k \ [[ $COMPREPLY == *= ]] && compopt -o nospace
--authentication-file --user' -- "$cur" ) )
fi fi
} && } &&
complete -F _smbcquotas smbcquotas complete -F _smbcquotas smbcquotas
@ -199,11 +242,13 @@ _smbpasswd()
_samba_debuglevel _samba_debuglevel
return 0 return 0
;; ;;
-U|-h|-w)
return 0
;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -c -x -d -e -D -n -r -R -m -U -h \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
-s -w -W -i -L' -- "$cur" ) )
fi fi
} && } &&
complete -F _smbpasswd smbpasswd complete -F _smbpasswd smbpasswd
@ -226,11 +271,17 @@ _smbtar()
_samba_debuglevel _samba_debuglevel
return 0 return 0
;; ;;
-N)
_filedir
return 0
;;
-p|-x|-b|-d|-u)
return 0
;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r -i -a -v -s -p -x -X -N -b -d -l -u -t' \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
-- "$cur" ) )
fi fi
} && } &&
complete -F _smbtar smbtar complete -F _smbtar smbtar
@ -241,7 +292,7 @@ _smbtree()
_init_completion -s || return _init_completion -s || return
case $prev in case $prev in
-s|-A|--authentication-file) -s|--configfile|-A|--authentication-file)
_filedir _filedir
return 0; return 0;
;; ;;
@ -253,14 +304,20 @@ _smbtree()
_samba_debuglevel _samba_debuglevel
return 0 return 0
;; ;;
-S|--signing)
_samba_signing
return 0
;;
-\?|--help|--usage|-U|--user)
return 0
;;
esac esac
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel -l \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
--log-basename -N -k -A --authentication-file -U --user\ [[ $COMPREPLY == *= ]] && compopt -o nospace
-h --help' -- "$cur" ) )
fi fi
} && } &&
complete -F _smbtree smbtree complete -F _smbtree smbtree

View File

@ -0,0 +1 @@
assert_source_completions smbcacls

View File

@ -0,0 +1 @@
assert_source_completions smbclient

View File

@ -0,0 +1 @@
assert_source_completions smbcquotas

View File

@ -0,0 +1 @@
assert_source_completions smbget

View File

@ -0,0 +1 @@
assert_source_completions smbpasswd

View File

@ -0,0 +1 @@
assert_source_completions smbtar

View File

@ -0,0 +1 @@
assert_source_completions smbtree

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbcacls -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbclient -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbcquotas -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbget -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbpasswd -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbtar -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "smbtree -"
sync_after_int
teardown