diff --git a/confluent_client/bin/nodefirmware b/confluent_client/bin/nodefirmware index 143b4819..e514d818 100755 --- a/confluent_client/bin/nodefirmware +++ b/confluent_client/bin/nodefirmware @@ -55,7 +55,8 @@ def printfirm(node, prefix, data): components = ['all'] argparser = optparse.OptionParser( - usage="Usage: %prog [update [--backup ]]|[]") + usage="Usage: " + "%prog [list][update [--backup ]]|[]") argparser.add_option('-b', '--backup', action='store_true', help='Target a backup bank rather than primary') (options, args) = argparser.parse_args() @@ -66,8 +67,12 @@ try: if args[1] == 'update': upfile = args[2] else: + if args[1] == 'list': + comps = args[2:] + else: + comps = args[1:] components = [] - for arg in args[1:]: + for arg in comps: components += arg.split(',') except IndexError: diff --git a/confluent_client/confluent_env.sh b/confluent_client/confluent_env.sh index d6f4ea28..f5cc7a5a 100644 --- a/confluent_client/confluent_env.sh +++ b/confluent_client/confluent_env.sh @@ -40,7 +40,7 @@ alias nodeshell='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CU -_confluent_np_completion() +_confluent_nodepower_completion() { CMPARGS=($COMP_LINE) if [ "${CMPARGS[-1]:0:1}" == '-' ]; then @@ -60,6 +60,50 @@ _confluent_np_completion() return; fi } + +_confluent_nodefirmware_completion() +{ + CMPARGS=($COMP_LINE) + NUMARGS=${#CMPARGS[@]} + if [ "${COMP_WORDS[-1]}" == '' ]; then + NUMARGS=$((NUMARGS+1)) + fi + if [ $NUMARGS == 3 ]; then + COMPREPLY=($(compgen -W "list update" -- ${COMP_WORDS[-1]})) + return; + fi + if [ $NUMARGS -gt 3 ] && [ ${CMPARGS[2]} == 'update' ]; then + compopt -o default + COMPREPLY=() + return + fi + if [ $NUMARGS -lt 3 ]; then + _confluent_nr_completion + return; + fi +} + +_confluent_nodesupport_completion() +{ + CMPARGS=($COMP_LINE) + NUMARGS=${#CMPARGS[@]} + if [ "${COMP_WORDS[-1]}" == '' ]; then + NUMARGS=$((NUMARGS+1)) + fi + if [ $NUMARGS == 3 ]; then + COMPREPLY=($(compgen -W "servicedata" -- ${COMP_WORDS[-1]})) + return; + fi + if [ $NUMARGS == 4 ] && [ ${CMPARGS[2]} == 'servicedata' ]; then + compopt -o dirnames + COMPREPLY=() + return + fi + if [ $NUMARGS -lt 3 ]; then + _confluent_nr_completion + return + fi +} _confluent_nr_completion() { INPUT=${COMP_WORDS[-1]} @@ -147,7 +191,7 @@ complete -F _confluent_nr_completion nodeboot complete -F _confluent_nr_completion nodeconfig complete -F _confluent_nn_completion nodeconsole complete -F _confluent_nr_completion nodeeventlog -complete -F _confluent_nr_completion nodefirmware +complete -F _confluent_nodefirmware_completion nodefirmware complete -F _confluent_ng_completion nodegroupattrib complete -F _confluent_ng_completion nodegroupremove complete -F _confluent_nr_completion nodehealth @@ -155,12 +199,12 @@ complete -F _confluent_nr_completion nodeidentify complete -F _confluent_nr_completion nodeinventory complete -F _confluent_nr_completion nodelist complete -F _confluent_nr_completion nodemedia -complete -F _confluent_np_completion nodepower +complete -F _confluent_nodepower_completion nodepower complete -F _confluent_nr_completion noderemove complete -F _confluent_nr_completion nodereseat complete -F _confluent_nr_completion noderun complete -F _confluent_nr_completion nodesensors complete -F _confluent_nr_completion nodesetboot complete -F _confluent_nr_completion nodeshell -complete -F _confluent_nr_completion nodesupport +complete -F _confluent_nodesupport_completion nodesupport diff --git a/confluent_client/doc/man/nodefirmware.ronn b/confluent_client/doc/man/nodefirmware.ronn index 2e6f5df6..6a9a60b0 100644 --- a/confluent_client/doc/man/nodefirmware.ronn +++ b/confluent_client/doc/man/nodefirmware.ronn @@ -4,7 +4,7 @@ nodefirmware(8) -- Report firmware information on confluent nodes ## SYNOPSIS `nodefirmware ` -`nodefirmware |core` +`nodefirmware list||core` `nodefirmware update [--backup] ` ## DESCRIPTION