Permalink
Browse files

fcoe-utils: Add BASH completion files for fcoeadm and fcoemon

These completion scripts will do general completion of
fcoeadm and fcoemon options. The only real shortcoming is
that fcoeadm cannot complete the <interval> value of the
'--stats' and '-s' options.

These scripts may or may not be added to the bash-completion
project and added to the distro's bash-completion packages.
'make install' will copy these scripts to the
/etc/bash_completion.d/ directory. However, they are not
usable unless the bash-completion package is installed.

Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
  • Loading branch information...
1 parent 964c51a commit 092bcb042275b514343ef4b137d1c28573e44f16 Robert Love committed May 4, 2011
Showing with 103 additions and 1 deletion.
  1. +7 −1 Makefile.am
  2. +54 −0 contrib/bash_completion/fcoeadm
  3. +42 −0 contrib/bash_completion/fcoemon
View
@@ -66,7 +66,13 @@ init_d_SCRIPTS = etc/initd/fcoe
dist_noinst_DATA = README COPYING INSTALL fcoe-utils.spec etc/config
+BASH_COMPLETION_DIR=/etc/bash_completion.d/
+
install-data-hook:
if [ ! -f ${DESTDIR}${fcoe_configdir}/config ] ; then \
cp ${srcdir}/etc/config ${DESTDIR}${fcoe_configdir}/config; \
- fi
+ fi; \
+ if [ ! -d "${BASH_COMPLETION_DIR}" ] ; then \
+ mkdir ${BASH_COMPLETION_DIR}; \
+ fi; \
+ cp -f ${srcdir}/contrib/bash_completion/* ${BASH_COMPLETION_DIR}
@@ -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
@@ -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

0 comments on commit 092bcb0

Please sign in to comment.