Skip to content

Commit

Permalink
Using clize as an alternative to argh
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChymera committed Apr 24, 2024
1 parent 8bf92ea commit 95ac640
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions tools/schemacode/bidsschematools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,15 @@

from clize import run

from .schema import export_schema, load_schema
from .schema import export
from .validator import validate_bids


def cli():
run({
'validate': ,
''
'validate': validate_bids,
'export': export,
})


@cli.command()
@click.option("--schema")
@click.option("--output", default="-")
@click.pass_context
def export(ctx, schema, output):
"""Export BIDS schema to JSON document"""
logger = logging.getLogger("bidsschematools")
schema = load_schema(schema)
text = export_schema(schema)
if output == "-":
logger.debug("Writing to stdout")
print(text)
else:
output = os.path.abspath(output)
logger.debug(f"Writing to {output}")
with open(output, "w") as fobj:
fobj.write(text)


if __name__ == "__main__":
cli()

0 comments on commit 95ac640

Please sign in to comment.