Skip to content

Commit

Permalink
Merge pull request #586 from OCR-D/no-args-help
Browse files Browse the repository at this point in the history
show help for no-arg processor calls, fix #562, fix #274
  • Loading branch information
kba authored Sep 22, 2020
2 parents f4b1979 + ae20fdb commit cb5b586
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ocrd/ocrd/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def ocrd_cli_wrap_processor(
overwrite=False,
**kwargs
):
if not sys.argv[1:]:
processorClass(workspace=None, show_help=True)
sys.exit(1)
if dump_json or help or version:
processorClass(workspace=None, dump_json=dump_json, show_help=help, show_version=version)
sys.exit()
else:
LOG = getLogger('ocrd_cli_wrap_processor')
if not mets or (is_local_filename(mets) and not isfile(get_local_filename(mets))):
processorClass(workspace=None, show_help=True)
sys.exit(1)
initLogging()
# LOG.info('kwargs=%s' % kwargs)
# Merge parameter overrides and parameters
Expand Down
1 change: 1 addition & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def invoke_cli(self, cli, args):
"""
self.capture_out_err() # XXX snapshot just before executing the CLI
code = 0
sys.argv[1:] = args # XXX necessary because sys.argv reflects pytest args not cli args
try:
cli.main(args=args)
except SystemExit as e:
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 cb5b586

Please sign in to comment.