nodeca / argparse

CLI arguments parser for node.js. JS port of python's argparse module.
Other
491 stars 73 forks source link

Update readme adding debug option #142

Closed dhulke closed 4 years ago

dhulke commented 4 years ago

While trying to do unit testing with a library that uses argparse, I found out that it would exit the test when an error was found. The only solution I found online was on this python SO thread.

I was able to reproduce the solution in node with the following code:

ArgumentParser.prototype.error = function(message) {
    throw new Error(message);
}
return new ArgumentParser();

Afterwards, out of curiosity I decided to go through the code and found out that it was checking for a debug variable and also that it already had this documented in a large comment describing all argparse options at the beginning of the code.

So would it be ok if a sent a PR copying the description for the debug option from the code to the readme?

rlidwka commented 4 years ago

debug option was only used internally for tests (whence the name "debug")

It's deprecated for now, overriding ArgumentParser.prototype.exit is the better way of approaching this issue (for now, until python devs fix exit_on_error option).

See also https://github.com/nodeca/argparse/issues/113#issuecomment-674118326