rdesktop: Use _parse_help, add/improve option completions and basic test case.

This commit is contained in:
Ville Skyttä 2011-05-04 23:21:06 +03:00
parent f9293cd3e8
commit 20a3d4d0bd
3 changed files with 41 additions and 9 deletions
completions
test
completion
lib/completions

@ -5,7 +5,7 @@ have rdesktop || return
_rdesktop()
{
local cur prev words cword
_init_completion || return
_init_completion -n : || return
case $prev in
-k)
@ -22,22 +22,33 @@ _rdesktop()
return 0
;;
-x)
COMPREPLY=( $( compgen -W 'b broadband m modem l lan' \
-- $cur ) )
COMPREPLY=( $( compgen -W 'broadband modem lan' -- "$cur" ) )
return 0
;;
-r)
# FIXME: should do -o nospace for the colon options
COMPREPLY=( $( compgen -W 'comport: disk: lptport: \
printer: sound: lspci scard' -- "$cur" ) )
case $cur in
sound:*)
COMPREPLY=( $( compgen -W 'local off remote' \
-- "${cur#sound:}" ) )
;;
*:*)
;;
*)
COMPREPLY=( $( compgen -W 'comport: disk: lptport: \
printer: sound: lspci scard' -- "$cur" ) )
[[ $COMPREPLY == *: ]] && compopt -o nospace
;;
esac
return 0
;;
-u|-d|-s|-c|-p|-n|-g|-S|-T|-X)
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -L \
-A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \
-0 -4 -5' -- "$cur" ) )
local opts=( $( _parse_help "$1" ) )
COMPREPLY=( $( compgen -W '${opts[@]%:}' -- "$cur" ) )
else
_known_hosts_real "$cur"
fi

@ -0,0 +1 @@
assert_source_completions rdesktop

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