mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Reallow to print result in json and readd compatibility for apps
This commit is contained in:
parent
59e8b0e035
commit
fb270f7240
1 changed files with 12 additions and 4 deletions
16
bin/yunohost
16
bin/yunohost
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os
|
||||||
|
|
||||||
from_source = False
|
from_source = False
|
||||||
|
|
||||||
|
@ -23,10 +23,18 @@ if __name__ == '__main__':
|
||||||
init(_from_source=from_source)
|
init(_from_source=from_source)
|
||||||
|
|
||||||
# Additional arguments
|
# Additional arguments
|
||||||
use_cache = True
|
cache = True
|
||||||
|
json = False
|
||||||
if '--no-cache' in sys.argv:
|
if '--no-cache' in sys.argv:
|
||||||
use_cache = False
|
cache = False
|
||||||
sys.argv.remove('--no-cache')
|
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 = list(sys.argv)
|
||||||
args.pop(0)
|
args.pop(0)
|
||||||
|
@ -46,5 +54,5 @@ if __name__ == '__main__':
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Execute the action
|
# Execute the action
|
||||||
ret = cli(['yunohost'], args, use_cache)
|
ret = cli(['yunohost'], args, print_json=json, use_cache=cache)
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
|
Loading…
Add table
Reference in a new issue