argparse icon indicating copy to clipboard operation
argparse copied to clipboard

Option to not exit on help or error

Open giann opened this issue 6 years ago • 2 comments

In the context in which I'm using argparse, it would be helpful if I could set an option to not exit when using --help or when the parsing fails.

giann avatar Mar 01 '19 08:03 giann

To not exit when using --help you can override the action of the help option:

parser:add_help {
   action = function() print(parser:get_help()) end
}

To not exit when parsing fails you can use :pparse() instead of :parse().

p-ouellette avatar Mar 28 '19 20:03 p-ouellette