1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
# bash completion for fcoeadm
#
## fcoeadm --help
#Version 1.0.17
#Usage: fcoeadm
# [-m|--mode fabric|vn2vn] [-c|--create] <ethX>
# [-d|--destroy] <ethX>
# [-r|--reset] <ethX>
# [-S|--Scan] <ethX>
# [-i|--interface] [<ethX>]
# [-t|--target] [<ethX>]
# [-l|--lun] [<ethX>]
# [-s|--stats] <ethX> [<interval>]
# [-v|--version]
# [-h|--help]
# This file must be updated with any changes to, or additions to the options.
# Could not get numeric value to work for the --stats interval
# Considered parsing output of --help to complete options
have fcoeadm && _available_fcoe_interfaces()
{
if [ "${1:-}" = -a ]; then
# list only devices that are up
COMPREPLY=( $( for f in /sys/class/net/* ; do if grep -q up $f/operstate ; then echo ${f##*/} ; fi ; done 2>/dev/null ))
else
# list all devices
COMPREPLY=( $( for f in /sys/class/net/* ; do echo ${f##*/} ; done 2>/dev/null ))
fi
COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
}
have fcoeadm && _fcoeadm_options()
{
local cur prev prev_prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-m --mode -c --create -d --destroy -r --reset -i --interface -t --target -l --lun -s --stats -S --Scan -h --help -v --version"
case "${prev}" in
-c|--create|-d|--destroy|-r|--reset|-s|--stats|-S|--Scan|-i|--interface|-t|--target|-l|--lun)
# only show interfaces that are up
_available_fcoe_interfaces -a
return 0
;;
-m|--mode)
COMPREPLY=( fabric vn2vn )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
return 0
;;
esac
case "${cur}" in
*)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
return 0
}
complete -F _fcoeadm_options fcoeadm
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
|