tcpdump: Use _parse_usage, add bunch of option completions and a basic test case.

This commit is contained in:
Ville Skyttä 2011-05-05 00:18:18 +03:00
parent 3334711726
commit ae9e140948
3 changed files with 42 additions and 3 deletions

View File

@ -16,12 +16,30 @@ _tcpdump()
_available_interfaces -a
return 0
;;
-m)
_filedir mib
return 0
;;
-T)
COMPREPLY=( $( compgen -W 'aodv cnfp rpc rtp rtcp snmp tftp vat
wb' -- "$cur" ) )
return 0
;;
-z)
COMPREPLY=( $( compgen -c -- "$cur" ) )
return 0
;;
-Z)
_allowed_users
return 0
;;
-B|-c|-C|-D|-E|-G|-M|-s|-W|-y)
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -d -e -f -l -n -N -O -p \
-q -R -S -t -u -v -x -C -F -i -m -r -s -T -w -E' -- "$cur" ) )
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
fi
} &&

View File

@ -0,0 +1 @@
assert_source_completions tcpdump

View File

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