bskinn / sphobjinv

Toolkit for manipulation and inspection of Sphinx objects.inv files
https://sphobjinv.readthedocs.io
MIT License
78 stars 9 forks source link

Add trap for null subparser to avoid exception in CLI corner case where options are provided but subparser is not #239

Closed bskinn closed 2 years ago

bskinn commented 2 years ago

~More idiomatic that way, and should provide a sensible argparse failed exit for things like sphobjinv --foo, instead of a mysterious exception deeper in the CLI code.~

~Annoying I had to monkeypatch argparse._VersionAction.__call__() to have the newlines not get swallowed up, but what can you do?~

While argparse is not likely to change much over time, the above approach (see (tag)[https://github.com/bskinn/sphobjinv/tree/wontfix-required-subparser]) just really seemed too brittle.

Much better just to trap for a null subparser in the CLI code and cleanly error-exit.