diff --git a/tools/schemacode/bidsschematools/__main__.py b/tools/schemacode/bidsschematools/__main__.py index c8d554cf0a..726798a0b4 100644 --- a/tools/schemacode/bidsschematools/__main__.py +++ b/tools/schemacode/bidsschematools/__main__.py @@ -4,6 +4,7 @@ import click from .schema import export_schema, load_schema +from .validator import validate_bids @click.group() @@ -32,5 +33,30 @@ def export(ctx, schema, output): fobj.write(text) +@cli.command() +@click.argument("in_paths", nargs=-1, required=True) +@click.option("--schema") +@click.option("--report", is_flag=False, flag_value=True, default=False) +@click.pass_context +def validate( + ctx, + schema, + in_paths, + report, +): + """Validate BIDS Schema""" + logger = logging.getLogger("bidsschematools") + validation_result = validate_bids( + in_paths, + schema_path=schema, + report_path=report, + ) + logger.debug("Printing out path_tracking in validation_result dictionary") + if validation_result["path_tracking"]: + print(validation_result["path_tracking"]) + + sys.exit(bool(validation_result["path_tracking"])) + + if __name__ == "__main__": cli()