Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show help for no-arg processor calls, fix #562, fix #274 #586

Merged
merged 3 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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