argparse icon indicating copy to clipboard operation
argparse copied to clipboard

Using BooleanOptionalAction and ArgumentDefaultsHelpFormatter results in repeating the default argument twice in the help ouput

Open pes10k opened this issue 1 year ago • 0 comments

// example.js
const argparseLib = require('argparse')

const parser = new argparseLib.ArgumentParser({
  formatter_class: argparseLib.ArgumentDefaultsHelpFormatter
})
parser.add_argument('-e', '--an-example', {
  help: 'An example flag.',
  action: argparseLib.BooleanOptionalAction,
  default: true
})
const args = parser.parse_args()
$ node example.js --help
usage: example.js [-h] [-e | --an-example | --no-an-example]

optional arguments:
  -h, --help            show this help message and exit
  -e, --an-example, --no-an-example
                        An example flag. (default: true) (default: true)

The issue is that (default: true) is repeated (e.g. (default: true) (default: true))

pes10k avatar Dec 03 '24 17:12 pes10k