Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions jsonschema/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# encoding=utf-8

import argparse
import json

from jsonschema import validate

def main():
parser = argparse.ArgumentParser(description='JSON Schema validator')
parser.add_argument('schema', help='filename of the JSON Schema')
parser.add_argument('document', help='filename of the JSON document to validate')
args = parser.parse_args()

schema = json.load(open(args.schema, 'r'))
document = json.load(open(args.document, 'r'))

validate(document, schema)
# validate raises if the document is invalid, and will show a Traceback to
# the user. If the document is valid, show a congratulating message.
print("√ JSON document is valid.")

if __name__ == '__main__':
main()
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@
license="MIT",
long_description=long_description,
url="http://github.com/Julian/jsonschema",
entry_points = {
'console_scripts': ['jsonschema = jsonschema.cli:main']
}
)