#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4
# Written by Alan Viars
import json, sys

from pjon.validate_pjson import validate_pjson


if __name__ == "__main__":

    if len(sys.argv)<2:
        print "You must suppy a ProviderJSON file to validate"
        print "Usage: validate-pjson [ProivderJSON]"
        sys.exit(1)
    else:
        pjson_file = sys.argv[1]



    #Open the file

    try:
        fh = open(pjson_file, 'r')

        j = fh.read()

        errors = validate_pjson(j)

        errors_json =  json.dumps(errors, indent =4)
        print errors_json
    except IOError:
        print "Could not open file %s." % (pjson_file)
        sys.exit(1)




