bw2 / ConfigArgParse

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

Add option to prevent config files from writing #246

Open Erotemic opened 3 years ago

Erotemic commented 3 years ago

I have a use case where I need to call parse_known_args to finish the contruction of my ArgumentParser instance. Thus, I don't want it to just write the config and exit. This PR adds a flag ignore_write_args to the parse_known_args method. When True, this prevents the config files from running.

If this change is desired, please advise on any additional change that would need to be made to support this feature (places where to change the docs / etc).

(My editor also removed whitespace, I can undo that the maintainers would like to keep the diff minimal)