diff --git a/validate-json.py b/validate-json.py index 59a89bc..8e72fe7 100755 --- a/validate-json.py +++ b/validate-json.py @@ -1,7 +1,28 @@ #!/usr/bin/env python3 +import sys import json +import argparse -with open ('config/panfwservices1.txt', 'r') as f: +# Parse all arguments +parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI") +parser.add_argument("-f", "--file", type=str, help="location of the JSON connector files") +parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true") +if len(sys.argv)==1: + parser.print_help(sys.stderr) + sys.exit(1) + +try: + args = parser.parse_args() + json_file = args.file + +except argparse.ArgumentError as e: + print(str(e)) + sys.exit() + +with open (json_file, 'r') as f: body = json.load(f) - print(body) + if args.pretty: + print(json.dumps(body, indent=4)) + else: + print(body)