From fb270f72403283d374ba8c66e436deefc22b86cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sat, 17 May 2014 21:52:36 +0200 Subject: [PATCH] [enh] Reallow to print result in json and readd compatibility for apps --- bin/yunohost | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/yunohost b/bin/yunohost index d73241c13..77814aea5 100755 --- a/bin/yunohost +++ b/bin/yunohost @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import sys -import os.path +import os from_source = False @@ -23,10 +23,18 @@ if __name__ == '__main__': init(_from_source=from_source) # Additional arguments - use_cache = True + cache = True + json = False if '--no-cache' in sys.argv: - use_cache = False + cache = False sys.argv.remove('--no-cache') + if '--json' in sys.argv: + json = True + sys.argv.remove('--json') + + ## Compatibility with previous moulinette + if not os.isatty(1): + json = True args = list(sys.argv) args.pop(0) @@ -46,5 +54,5 @@ if __name__ == '__main__': sys.exit(1) # Execute the action - ret = cli(['yunohost'], args, use_cache) + ret = cli(['yunohost'], args, print_json=json, use_cache=cache) sys.exit(ret)