@@ -54,6 +54,7 @@ def main():
5454 parser .add_argument ('--directory' , '-d' , default = '.' , help = 'Directory to scan for files' )
5555 parser .add_argument ('--check-json' , action = 'store_true' , help = 'Check JSON files' )
5656 parser .add_argument ('--check-yaml' , action = 'store_true' , help = 'Check YAML files' )
57+ parser .add_argument ('--changed-files' , nargs = '*' , help = 'List of changed files to validate' )
5758
5859 args = parser .parse_args ()
5960
@@ -62,17 +63,26 @@ def main():
6263
6364 all_valid = True
6465
65- if args .check_json :
66- json_files = find_files (args .directory , '.json' )
67- print (f"Found { len (json_files )} JSON files" )
66+ # If changed files are provided, filter them by extension
67+ if args .changed_files :
68+ json_files = [f for f in args .changed_files if f .endswith ('.json' )]
69+ yaml_files = [f for f in args .changed_files if f .endswith ('.yaml' ) or f .endswith ('.yml' )]
70+ else :
71+ # Otherwise, find all files in directory
72+ json_files = find_files (args .directory , '.json' ) if args .check_json else []
73+ yaml_files = []
74+ if args .check_yaml :
75+ yaml_files = find_files (args .directory , '.yaml' )
76+ yaml_files += find_files (args .directory , '.yml' )
77+
78+ if args .check_json and json_files :
79+ print (f"Found { len (json_files )} JSON files to validate" )
6880 for file_path in json_files :
6981 if not validate_json (file_path ):
7082 all_valid = False
7183
72- if args .check_yaml :
73- yaml_files = find_files (args .directory , '.yaml' )
74- yaml_files += find_files (args .directory , '.yml' )
75- print (f"Found { len (yaml_files )} YAML files" )
84+ if args .check_yaml and yaml_files :
85+ print (f"Found { len (yaml_files )} YAML files to validate" )
7686 for file_path in yaml_files :
7787 if not validate_yaml (file_path ):
7888 all_valid = False
0 commit comments