Is there a way to access the help lines for specific arguments of the parser library object of the argument?
I want to print the contents of the help line if the option was present on the command line. Not the full help text that Argument Parser can display through ArgumentParser.print_help.
So, something in these lines:
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--do_x", help='the program will do X')
if do_x:
print(parser.<WHAT DO I HAVE TO PUT HERE?>('do_x')
And this is the required behavior
$ program -d
the program will execute X
source
share