We build a precise error message, but then bury it under a wall of text
produced by print_usage(). The printing of help (or some subset of it) on
parsing error is just useless. Most likely the user made a typo in an option,
and printing a few dozen lines (and more in the future) of unhelpful
semi-related information is counterproductive.
I'm surprised that argparse doesn't make this configurable, but looking at the
code, it seems that the behaviour is hardcoded. Docs and stackoverflow also
yield no hints.
Iterator,
List,
NamedTuple,
+ NoReturn,
Optional,
Sequence,
Set,
# return the modified argument list
return new_arg_strings
+ def error(self, message: str) -> NoReturn:
+ # This is a copy of super's method but with self.print_usage() removed
+ self.exit(2, f'{self.prog}: error: {message}\n')
+
COMPRESSION_ALGORITHMS = "zlib", "lzo", "zstd", "lz4", "xz"