Skip to content
Snippets Groups Projects
Commit 8ce78f0f authored by Lionel Morin's avatar Lionel Morin
Browse files

Merge branch 'feature/348_ZcliOptionBatch' into 'develop'

348 option batch ok

See merge request !24
parents 46b3b3be ecb7c01a
No related branches found
No related tags found
1 merge request!24348 option batch ok
Pipeline #480 failed
......@@ -17,10 +17,16 @@ def main():
OUTPUT = 'yaml'
list_msgs = 0
prettyjson = 2
no_msg = False
if '--json' in sys.argv:
OUTPUT = 'json'
sys.argv.remove('--json')
if '--batch' in sys.argv:
no_msg = True
sys.argv.remove('--batch')
if '--no-pretty' in sys.argv:
prettyjson = None
......@@ -99,20 +105,28 @@ def main():
Utiliser <{progname} list> pour lister les commandes disponibles.\n""")
sys.exit(0)
# ask for missing parameters
for key in config.value.mandatory():
if not config.option(key).option.issymlinkoption():
val_ok = False
while not val_ok:
text = input("* "+config.option(key).option.doc() + " : ")
try:
if config.option(key).option.type() == 'integer':
config.option(key).value.set(int(text))
else:
config.option(key).value.set(text)
val_ok = True
except Exception as err:
print('\nValeur invalide: {}\n'.format(err))
result = send(URL, VERSION, config)
if not no_msg:
for key in config.value.mandatory():
if not config.option(key).option.issymlinkoption():
val_ok = False
while not val_ok:
text = input("* "+config.option(key).option.doc() + " : ")
try:
if config.option(key).option.type() == 'integer':
config.option(key).value.set(int(text))
else:
config.option(key).value.set(text)
val_ok = True
except Exception as err:
print('\nValeur invalide: {}\n'.format(err))
result = send(URL, VERSION, config)
else:
result = send(URL, VERSION, config)
if "Erreur" in result:
print("ERREUR: paramètres requis manquants.")
print("Les paramètres nécessaires sont :" + ", ".join((key for key in config.value.mandatory() if not config.option(key).option.issymlinkoption())))
sys.exit(1)
if OUTPUT == "yaml":
print(yaml.dump(result, default_flow_style=False, allow_unicode=True))
else:
......@@ -146,6 +160,10 @@ Client pour interroger un serveur Zéphir.
--no-pretty
Affiche le résultat json brut
{progname} --batch <message> [paramètres]
Execute le message avec ses paramètres, en mode batch
""")
sys.exit(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment