inveniosoftware / dojson

Simple pythonic JSON to JSON converter.
https://dojson.readthedocs.io
Other
10 stars 29 forks source link

RFC Enhancing data with $schema #73

Closed jirikuncar closed 8 years ago

jirikuncar commented 8 years ago

cc @SamiHiltunen @hachreak @egabancho

hachreak commented 8 years ago

For the extra arguments: before, I was wondering if we can do something like:

@click.group()
def do():
    """Command line interface."""

@do.command(name='marc21')
@click.option('-i', '--input', 'source', type=click.File('rb'),
              default=sys.stdin)
@click.option('-l', '--load', callback=open_entry_point('dojson.cli.load'),
              default='json')
@click.option('-d', '--dump', callback=open_entry_point('dojson.cli.dump'),
              default='json')
@click.option('--strict', is_flag=True, default=False,
              help='Raise when there is not matching rule for a key.')
def apply_rule_marc21(source, load, dump, strict):
    ...

@do.command(name='to_marc21')
@click.option('-i', '--input', 'source', type=click.File('rb'),
              default=sys.stdin)
@click.option('-l', '--load', callback=open_entry_point('dojson.cli.load'),
              default='json')
@click.option('-d', '--dump', callback=open_entry_point('dojson.cli.dump'),
              default='json')
@click.option('-f', '--filename')
@click.option('--strict', is_flag=True, default=False,
              help='Raise when there is not matching rule for a key.')
def apply_rule_to_marc21(source, load, dump, filename, strict):
    ...

In this way we can add all options we want. Is it possible to do like a "subgroup" with Click?

jirikuncar commented 8 years ago

@hachreak it isn't about the arguments for rules but about the extra args for dump.