You need to call
parse_args()
after adding your arguments, and also a double
--
in front of the argument name. Try:
import argparse
args = argparse.ArgumentParser()
args.add_argument("-p", "--port", help="Please enter the port number",action="store_true")
args.parse_args()
Also note that this parser will not accept any argument value, since port is defined as
"store_true"