From e9faa60dd62c6a8db3a5bfc4558021c1473c316a Mon Sep 17 00:00:00 2001 From: SRE Date: Thu, 6 Apr 2017 10:07:54 +0200 Subject: [PATCH] products completion after --products or -p --- commands/config.py | 7 +++++++ complete_sat.sh | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/config.py b/commands/config.py index 3246548..d315df5 100644 --- a/commands/config.py +++ b/commands/config.py @@ -47,6 +47,8 @@ parser.add_option('c', 'copy', 'boolean', 'copy', \tIf a name is given the new config file takes the given name.""")) parser.add_option('n', 'no_label', 'boolean', 'no_label', _("Internal use: do not print labels, Works only with --value and --list.")) +parser.add_option('', 'completion', 'boolean', 'completion', + _("Internal use: print only keys, works only with --value.")) parser.add_option('s', 'schema', 'boolean', 'schema', _("Internal use.")) @@ -949,5 +951,10 @@ def run(args, runner, logger): src.printcolors.printcLabel(runner.cfg.VARS.application), 3) logger.write("\n", 2, False) show_patchs(runner.cfg, logger) + + # case: print all the products name of the application (internal use for completion) + elif options.completion: + for product_name in runner.cfg.APPLICATION.products.keys(): + logger.write("%s\n" % product_name) diff --git a/complete_sat.sh b/complete_sat.sh index 29ae207..02d54c4 100755 --- a/complete_sat.sh +++ b/complete_sat.sh @@ -67,7 +67,7 @@ _show_products() { if [[ $appli != $prev ]] then - opts=$(for x in `$SAT_PATH/sat -s config $appli -nv APPLICATION.products` + opts=$(for x in `$SAT_PATH/sat config $appli --completion` do echo ${x}; done) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) @@ -138,12 +138,12 @@ _salomeTools_complete() fi # show list of products - if [[ ${prev} == "--product" || ${prev} == "-p" ]] + if [[ ${prev} == "--product" || ${prev} == "-p" || ${prev} == "--info" || ${prev} == "-i" ]] then appli="${COMP_WORDS[2]}" if [[ ${command} != "source" ]] then - opts=$(for x in `$SAT_PATH/sat config $appli -nv APPLICATION.products` + opts=$(for x in `$SAT_PATH/sat config $appli --completion` do echo ${x}; done) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) -- 2.39.2