I've had a look around, but couldn't find anything.
Basically I was wondering if it was possible to use getpass.getpass() with argparse.
At the moment I have the following as a work around, I was just wondering if there was a better way:
import argparse
import getpass
parser = argparse.ArgumentParser(description="Some description")
parser.add_argument('-p', metavar="password", default="foobarblah123", help="password for user (default to prompt user)")
...
parsed_args = parser.parse_args()
args = vars(parsed_args)
user_pass = args['p']
if user_pass == "foobarblah123":
user_pass = getpass.getpass()
I'm pretty sure this is not the best way to handle this, however, there is a requirement to have a command line option for the password ... best practice or not.
Thanks.