bw2 / ConfigArgParse

A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.
MIT License
728 stars 121 forks source link

Write config file argument with default value fails #150

Open othalan opened 5 years ago

othalan commented 5 years ago

Using the flag is_write-out_config_file_arg with a default value does not permit use of the default argument.

Code:

import configargparse
parser = configargparse.get_parser()

parser = cls.get_parser()

parser.add('--test-arg',
                action = 'store',
                help    = "Write this command line to a configuration file")
parser.add('--config-write',
                is_write_out_config_file_arg = True,
                default                      = str('~/.test_config.ini'),
                help                         = "Write this command line to a configuration file")

Command Line:

./my_app --test-arg testArgValue --config-write

The above command results in an error, saying that --config-write requires a value even though a default is provided and shows on the help display.