-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
Description
this would be useful as a command line tool as well, something like:
__main__.py
#!/usr/bin/env python
"""
Cli jsonmerge tool.
"""
import argparse
import json
import jsonmerge
ARGP = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawTextHelpFormatter,
)
ARGP.add_argument('files', nargs='+', help='Json Input Files')
ARGP.add_argument('--merge-strategy', '-X', help='Root node merge strategy')
def main(argp=None):
if argp is None:
argp = ARGP.parse_args()
schema = dict()
if argp.schema:
with open(argp.schema) as file_handle:
schema = json.load(file_handle)
result = {}
for file in argp.files:
with open(file) as file_handle:
result = jsonmerge.merge(result, json.load(file_handle), schema)
print(json.dumps(result, indent=4))
if __name__ == '__main__':
main()
With
- an entrypoint defined in the setup.sh
the ability to apply a merge strategy to the root node- ability to load a schema file as well?
That would be great.
filipbartek and harvimt