|
@@ -382,25 +382,40 @@ def main():
|
382
|
382
|
schema = None
|
383
|
383
|
|
384
|
384
|
if schema:
|
385
|
|
- print("Generating JSON ...")
|
386
|
|
- dump_json(schema, Path('schema.json'))
|
387
|
|
- group_options(schema)
|
388
|
|
- dump_json(schema, Path('schema_grouped.json'))
|
389
|
|
-
|
390
|
|
- try:
|
391
|
|
- import yaml
|
392
|
|
- except ImportError:
|
393
|
|
- print("Installing YAML module ...")
|
394
|
|
- import subprocess
|
|
385
|
+
|
|
386
|
+ # Get the first command line argument
|
|
387
|
+ import sys
|
|
388
|
+ if len(sys.argv) > 1:
|
|
389
|
+ arg = sys.argv[1]
|
|
390
|
+ else:
|
|
391
|
+ arg = 'some'
|
|
392
|
+
|
|
393
|
+ # JSON schema
|
|
394
|
+ if arg in ['some', 'json', 'jsons']:
|
|
395
|
+ print("Generating JSON ...")
|
|
396
|
+ dump_json(schema, Path('schema.json'))
|
|
397
|
+
|
|
398
|
+ # JSON schema (wildcard names)
|
|
399
|
+ if arg in ['group', 'jsons']:
|
|
400
|
+ group_options(schema)
|
|
401
|
+ dump_json(schema, Path('schema_grouped.json'))
|
|
402
|
+
|
|
403
|
+ # YAML
|
|
404
|
+ if arg in ['some', 'yml', 'yaml']:
|
395
|
405
|
try:
|
396
|
|
- subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml'])
|
397
|
406
|
import yaml
|
398
|
|
- except:
|
399
|
|
- print("Failed to install YAML module")
|
400
|
|
- return
|
401
|
|
-
|
402
|
|
- print("Generating YML ...")
|
403
|
|
- dump_yaml(schema, Path('schema.yml'))
|
|
407
|
+ except ImportError:
|
|
408
|
+ print("Installing YAML module ...")
|
|
409
|
+ import subprocess
|
|
410
|
+ try:
|
|
411
|
+ subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml'])
|
|
412
|
+ import yaml
|
|
413
|
+ except:
|
|
414
|
+ print("Failed to install YAML module")
|
|
415
|
+ return
|
|
416
|
+
|
|
417
|
+ print("Generating YML ...")
|
|
418
|
+ dump_yaml(schema, Path('schema.yml'))
|
404
|
419
|
|
405
|
420
|
if __name__ == '__main__':
|
406
|
421
|
main()
|