show help for no-arg processor calls, fix #562, fix #274#586
Merged
Conversation
This was
linked to
issues
Sep 2, 2020
Codecov Report
@@ Coverage Diff @@
## master #586 +/- ##
=======================================
Coverage 84.87% 84.87%
=======================================
Files 52 52
Lines 2890 2890
Branches 564 564
=======================================
Hits 2453 2453
Misses 328 328
Partials 109 109
Continue to review full report at Codecov.
|
Contributor
|
This sometimes breaks running a test using The call/ Edit: I worked around it by setting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a surprisingly tricky-to-implement problem: We want processor calls without any arguments to print the help screen and exit with code1, i.e. ifsys.argv[2:] == [].It really isn't, it was just hard to test because sys.argv contained the arguments to pytest, not to the CLI. Turns out, sys.argv can be overridden at runtime for the tests and checking
not sys.argv[1:]was enoughHowever, I could not find a way to get the un-procesed command line arguments to click. `get_current_context()` does have an `args` property but that only contains the remaining positional arguments after parsing.
If anyone knows a better way to get the click equivalent of
sys.argv[2:], I'd be interested!For now, I've disabled the defaults for
input_file_grp/output_file_grp(as proposed in #274) and check for all relevant CLI options one-by-one:As I said before, I would prefer a more robust solution. The clause above will also trigger for processors being called with
--mets mets.xmlbut neither input nor output file group (such as the ocrd-sanitize processor...).