Skip to content

Commit

Permalink
feat(cli): Add command to export metaschema
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Aug 21, 2024
1 parent e5db69d commit 9ad4237
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/schemacode/bidsschematools/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import logging
import os
import sys

import click

if sys.version_info < (3, 9):
from importlib_resources import files
else:
from importlib.resources import files


from .schema import export_schema, load_schema


Expand Down Expand Up @@ -32,5 +39,19 @@ def export(ctx, schema, output):
fobj.write(text)


@cli.command()
@click.option("--output", default="-")
@click.pass_context
def export_metaschema(ctx, output):
"""Export BIDS schema to JSON document"""
metaschema = files("bidsschematools.data").joinpath("metaschema.json").read_text()
if output == "-":
print(metaschema, end="")
else:
output = os.path.abspath(output)
with open(output, "w") as fobj:
fobj.write(metaschema)


if __name__ == "__main__":
cli()

0 comments on commit 9ad4237

Please sign in to comment.