Skip to content

Commit

Permalink
show help for no-arg processor calls, fix #562, fix #274
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Sep 2, 2020
1 parent 8dafbac commit 98cb095
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions ocrd/ocrd/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def ocrd_cli_wrap_processor(
overwrite=False,
**kwargs
):
if not (dump_json or help or version or overwrite) and \
mets == 'mets.xml' and \
not (kwargs['input_file_grp'] or kwargs['output_file_grp']):
processorClass(workspace=None, show_help=True)
sys.exit(1)
if dump_json or help or version:
setOverrideLogLevel('OFF', silent=True)
processorClass(workspace=None, dump_json=dump_json, show_help=help, show_version=version)
Expand Down Expand Up @@ -127,8 +132,8 @@ def cli(mets_url):
# TODO OCR-D/core#274
# click.option('-I', '--input-file-grp', help='File group(s) used as input. **required**'),
# click.option('-O', '--output-file-grp', help='File group(s) used as output. **required**'),
click.option('-I', '--input-file-grp', help='File group(s) used as input.', default='INPUT'),
click.option('-O', '--output-file-grp', help='File group(s) used as output.', default='OUTPUT'),
click.option('-I', '--input-file-grp', help='File group(s) used as input.'),
click.option('-O', '--output-file-grp', help='File group(s) used as output.'),
click.option('-g', '--page-id', help="ID(s) of the pages to process"),
click.option('--overwrite', help="Overwrite the output file group or a page range (--page-id)", is_flag=True, default=False),
parameter_option,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def test_processor_no_mets(self):
https://github.com/OCR-D/spec/pull/156
"""
_, out_help, _ = self.invoke_cli(cli_dummy_processor, ['--help'])
exit_code, out_none, _ = self.invoke_cli(cli_dummy_processor, [])
exit_code, out_none, err = self.invoke_cli(cli_dummy_processor, [])
print("exit_code=%s\nout=%s\nerr=%s" % (exit_code, out_none, err))
# assert 0
self.assertEqual(exit_code, 1)
self.assertEqual(out_help, out_none)

Expand Down

0 comments on commit 98cb095

Please sign in to comment.