1- import sys
21import argparse
2+ import sys
33
44from schemadiff .allow_list import read_allowed_changes
55from schemadiff .diff .schema import Schema
6- from schemadiff .schema_loader import SchemaLoader
76from schemadiff .formatting import print_diff , print_json
7+ from schemadiff .schema_loader import SchemaLoader
88from schemadiff .validation import rules_list , validate_changes
99
1010
@@ -14,31 +14,31 @@ def cli():
1414
1515
1616def parse_args (arguments ):
17- parser = argparse .ArgumentParser (description = ' Schema comparator' )
18- parser .add_argument ('-o' , ' --old-schema' ,
19- dest = ' old_schema' ,
20- type = argparse .FileType ('r' , encoding = ' UTF-8' ),
21- help = ' Path to old graphql schema file' ,
17+ parser = argparse .ArgumentParser (description = " Schema comparator" )
18+ parser .add_argument ("-o" , " --old-schema" ,
19+ dest = " old_schema" ,
20+ type = argparse .FileType ("r" , encoding = " UTF-8" ),
21+ help = " Path to old graphql schema file" ,
2222 required = True )
23- parser .add_argument ('-n' , ' --new-schema' ,
24- dest = ' new_schema' ,
25- type = argparse .FileType ('r' , encoding = ' UTF-8' ),
26- help = ' Path to new graphql schema file' ,
23+ parser .add_argument ("-n" , " --new-schema" ,
24+ dest = " new_schema" ,
25+ type = argparse .FileType ("r" , encoding = " UTF-8" ),
26+ help = " Path to new graphql schema file" ,
2727 required = True )
28- parser .add_argument ('-j' , ' --as-json' ,
29- action = ' store_true' ,
30- help = ' Output a detailed summary of changes in json format' ,
28+ parser .add_argument ("-j" , " --as-json" ,
29+ action = " store_true" ,
30+ help = " Output a detailed summary of changes in json format" ,
3131 required = False )
32- parser .add_argument ('-a' , ' --allow-list' ,
33- type = argparse .FileType ('r' , encoding = ' UTF-8' ),
34- help = ' Path to the allowed list of changes' )
35- parser .add_argument ('-t' , ' --tolerant' ,
36- action = ' store_true' ,
32+ parser .add_argument ("-a" , " --allow-list" ,
33+ type = argparse .FileType ("r" , encoding = " UTF-8" ),
34+ help = " Path to the allowed list of changes" )
35+ parser .add_argument ("-t" , " --tolerant" ,
36+ action = " store_true" ,
3737 help = "Tolerant mode. Error out only if there's a breaking change but allow dangerous changes" )
38- parser .add_argument ('-s' , ' --strict' ,
39- action = ' store_true' ,
38+ parser .add_argument ("-s" , " --strict" ,
39+ action = " store_true" ,
4040 help = "Strict mode. Error out on dangerous and breaking changes." )
41- parser .add_argument ('-r' , ' --validation-rules' , choices = rules_list (), nargs = '*' ,
41+ parser .add_argument ("-r" , " --validation-rules" , choices = rules_list (), nargs = "*" ,
4242 help = "Evaluate rules mode. Error out on changes that fail some validation rule." )
4343
4444 return parser .parse_args (arguments )
@@ -79,5 +79,5 @@ def exit_code(changes, strict, some_change_is_restricted, tolerant) -> int:
7979 return exit_code
8080
8181
82- if __name__ == ' __main__' :
82+ if __name__ == " __main__" :
8383 sys .exit (cli ())
0 commit comments