I have the following parser:
def parse(argv: list, actions: list) -> list:
p = argparse.ArgumentParser()
p.add_argument('action', type=str, choices=actions)
p.add_argument('args', nargs='*')
try:
return p.parse_args(argv)
except SystemExit:
return None
If I type in an invalid option, I get:
usage: main.py [-h] {update,help} [args [args ...]]
main.py: error: argument action: invalid choice: 'test' (choose from 'update', 'help')
in stdout. I don't want to get ANY responses out. Is there a way to mute error responses? I just want to get None
if user types invalid argument.