aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorTeddy Wing2022-06-25 18:08:41 +0200
committerTeddy Wing2022-06-25 18:08:41 +0200
commitc175d9dc7e3df6af0905b7b597fae67539ce6c6c (patch)
tree1456ea9939018c9e689860d9544ebf4000bafe19 /README.md
parenta9b373cc4798f2095117ed8e38ceb99c21a1a96d (diff)
downloadcws-status-c175d9dc7e3df6af0905b7b597fae67539ce6c6c.tar.bz2
cws-status: Exit with code `EX_USAGE` on argument parse errorv0.0.1
I tried catching the `argparse.ArgumentError` as described here, but that didn't seem to work: https://docs.python.org/3.9/library/argparse.html#exit-on-error When I wrapped `args = argparser.parse_args()` in a `try` block, it raised a `SystemExit` exception instead of `argparse.ArgumentError`. Take inspiration from some of the suggestions in this Stack Overflow answer: https://stackoverflow.com/questions/5943249/python-argparse-and-controlling-overriding-the-exit-status-code Since we just want to change the exit code, call `argparse.ArgumentParser`'s `error()` method and exit with the error code we want.
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions