How to handle invalid arguments with argparse in Python?
I use argparse to parse command line arguments and by default on receiving invalid arguments it prints help message and exits.
#foo.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("echo")
args = parser.parse_args()
How to catch this exception when it receives invalid arguments?