[enh] Reallow to print result in json and readd compatibility for apps

This commit is contained in:
Jérôme Lebleu 2014-05-17 21:52:36 +02:00
parent 59e8b0e035
commit fb270f7240

View file

@ -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)