Sunday 30 October 2022

Suppressing option processing after a non-option command-line argument

I am writing a wrapper program which accepts a list of arguments that are going to be passed to another program, and some options that are specific to my wrapper. To avoid confusion regarding which options go where, I want any appearance of a non-option argument to suppress processing further arguments as options, as if a -- argument appeared just before it. In other words, something similar to what xterm -e does.

parse_known_args is obviously wrong, because it will ignore unknown options, and pick up options appearing after a non-option.

What is the best way to accomplish this in Python? I would prefer a solution using argparse over parsing the command line manually.



from Suppressing option processing after a non-option command-line argument

No comments:

Post a Comment