Skip to content

Commit

Permalink
Better handling of SystemExit arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Jul 31, 2024
1 parent d69e28c commit 33f44dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/darkgraylib/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ def parse_args(parser: ArgumentParser, argv: list[str]) -> Namespace:
try:
return parser.parse_args(argv)
except SystemExit as exc_info:
exit_code, = exc_info.args
sys.exit(EXIT_CODE_CMDLINE_ERROR if exit_code == 2 else exit_code)
if exc_info.args == (2,):
# Change all exceptions from argparse to exit code 3 (cmdline error)
sys.exit(EXIT_CODE_CMDLINE_ERROR)
# For other exit codes, exit with the original code
raise


def parse_command_line(
Expand Down

0 comments on commit 33f44dc

Please sign in to comment.