I'm currently working on a Python script where I'd like to have general options. That is because the ultimate goal is to output a URL that has parameters, and each parameter corresponds to an input variable. So maybe the URL has the username parameter, or the date parameter, or the domain parameter, etc. If a user wants to input a username, they can type something like:
script.py -u johndoe
Then the script would take the part after -u, equal it to the variable username, and then insert it into the URL at the appropriate place.
How can I do something like this? I tried doing something with this code, but I don't know where to start, how can I use input variables alongside argparse.
import argparse
parser.add_argument('-u', '--username', action='N', type=str, nargs='+',
help='What's the username?')
args = parser.parse_args()