my application uses a database, so when adding a new element (from command line) I want to check if this one is already in the database, what I do with the "type" parameter of add_argument:
def check_uniq(project_name):
if Project.exists(project_name):
raise argparse.ArgumentTypeError(
return project_name
this is working just fine, however to make think easier to the final user I'd like to add a --force
option to my arguments so this variable is tested and delete before to add and in this case do note raise the argument. How can I access within the check_uniq to the --force option ?