I am using Argparse module in python for developing a Command Line Tool. Here's the parser code:
from argparse import ArgumentParser
def arguments():
parser = ArgumentParser()
parser.add_argument('-c' , '--comms' , action = "store" , default = None , type = str , dest = "command",
help = 'Choosing a Command')
parser.add_argument( '-s' , '--search' , action = 'store' , default = None , type = str , dest = 'search_path' ,
help = 'Search for a command' )
parser.add_argument( '-f' , '--config' , action = 'store_true' ,
help = 'Show the present configuration')
parser.add_argument('--flush_details' , action = "store_false" ,
help = "Flushes the current commands buffer")
return parser.parse_args()
def main():
parser_results = arguments()
#More code comes here to analyze the results
However, when I run the code python foo.py --help
, it never runs the script post parsing the arguments. Is there anything I can do to stop the behaviour. I want to analyse the parser results even if it is just asked for --help
switch.
Would like to know what can I do to continue the script even after --help
has been used