This patch adds completion scripts for fcoeadm, fcoemon, lldpad and lldptool. They are very simple scripts, but do the trick. A shortcoming of the lldptool completion script is that it does not differentiate between options and commands.
Signed-off-by: Robert Love <robert.w.l...@intel.com> --- completions/fcoeadm | 54 ++++++++++++++++++++++++++++++++++++ completions/fcoemon | 42 ++++++++++++++++++++++++++++ completions/lldpad | 50 ++++++++++++++++++++++++++++++++++ completions/lldptool | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+), 0 deletions(-) create mode 100644 completions/fcoeadm create mode 100644 completions/fcoemon create mode 100644 completions/lldpad create mode 100644 completions/lldptool diff --git a/completions/fcoeadm b/completions/fcoeadm new file mode 100644 index 0000000..60f902d --- /dev/null +++ b/completions/fcoeadm @@ -0,0 +1,54 @@ +# bash completion for fcoeadm +# +## fcoeadm --help +#Version 1.0.17 +#Usage: fcoeadm +# [-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 && _fcoeadm_options() +{ + local cur prev prev_prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-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) + _available_interfaces + 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 \ No newline at end of file diff --git a/completions/fcoemon b/completions/fcoemon new file mode 100644 index 0000000..e9c7d6b --- /dev/null +++ b/completions/fcoemon @@ -0,0 +1,42 @@ +# bash completion for fcoemon +# + +## fcoemon --help +#Usage: fcoemon +# [-f|--foreground] +# [-d|--debug] +# [-s|--syslog] +# [-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 fcoemon && _fcoemon_options() +{ + local cur prev prev_prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-f --foreground -d --debug -s --syslog -v --version -h --help" + + case "${cur}" in + *) + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + esac + + return 0 +} +complete -F _fcoemon_options fcoemon + +# 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 \ No newline at end of file diff --git a/completions/lldpad b/completions/lldpad new file mode 100644 index 0000000..5e704f8 --- /dev/null +++ b/completions/lldpad @@ -0,0 +1,50 @@ +# bash completion for lldpad +# +## lldpad --help +# usage: lldpad [-hdksv] [-f configfile] +# options: +# -h show this usage +# -f use configfile instead of default +# -d run daemon in the background +# -k terminate current running lldpad +# -s remove lldpad state records +# -v show version +# -V set syslog level + +# 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 lldpad && _lldpad_options() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-h -f -d -k -s -v -V" + + case "${cur}" in + *) + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + ;; + esac + + case "${prev}" in + -f) + _filedir + return 0 + ;; + esac + + return 0 +} +complete -F _lldpad_options lldpad + +# 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 \ No newline at end of file diff --git a/completions/lldptool b/completions/lldptool new file mode 100644 index 0000000..3cb9a95 --- /dev/null +++ b/completions/lldptool @@ -0,0 +1,74 @@ +# bash completion for lldptool +# +## lldptool --help +# lldptool v0.9.41 +# Copyright (c) 2007-2010, Intel Corporation +# +# Substantially modified from: hostapd_cli v 0.5.7 +# Copyright (c) 2004-2007, Jouni Malinen <j...@w1.fi> and contributors +# +# Usage: +# lldptool <command> [options] [arg] general command line usage format +# lldptool go into interactive mode +# <command> [options] [arg] general interactive command format +# +# Options: +# -i [ifname] network interface +# -V [tlvid] TLV identifier +# may be numeric or keyword (see below) +# -n "neighbor" option for command +# -a "add" option for command +# -d "remove" option for command +# -r show raw message +# -R show only raw messages +# +# Commands: +# license show license information +# -h|help show command usage information +# -v|version show version +# -q|quit exit lldptool (interactive mode) +# -S|stats get LLDP statistics for ifname +# -t|get-tlv get TLVs from ifname +# -T|set-tlv set arg for tlvid to value +# -l|get-lldp get the LLDP parameters for ifname +# -L|set-lldp set the LLDP parameter for ifname + +# 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 lldptool && _lldptool_options() +{ + local cur prev opts cmds opts_and_cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmds="license -h help -v version -q quit -s stats -t get-tlv -T set-tlv -l get-lldp -L set-lldp" + opts="-i -V -n -a -d -r -R" + opts_and_cmds="$opts $cmds" + + case "${cur}" in + *) + COMPREPLY=( $(compgen -W "${opts_and_cmds}" -- ${cur}) ) + ;; + esac + + case "${prev}" in + -i) + _available_interfaces + return 0 + ;; + esac + + return 0 +} +complete -F _lldptool_options lldptool + +# 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 \ No newline at end of file _______________________________________________ Bash-completion-devel mailing list Bash-completion-devel@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/bash-completion-devel