dominiontabs
dominiontabs copied to clipboard
Add functionality to save sets of options for later re-use
I'd actually like to write a general library for argparse to do this for any app - I've run into this need several times. Barring that, just saving them to a JSON or config file would do.
Actually, it looks like there's might be a more acceptable solution in https://github.com/bw2/ConfigArgParse since the last time I looked.
I stumbled upon this independently recently. Looks like there have been recent updates on https://github.com/bw2/ConfigArgParse. See also https://pypi.org/project/ConfigArgParse/.
I did a little playing around. Can specify a config input file. Command line arguments overwrite the config input file values (good). Can specify a file to write resulting config (good.) So far I have found two minor annoyances with the resulting write:
*If you specify a config file for input via a double --, that argument is included in the output, even though all the values from the file are also included. So if you used that output file as input, you would reload the original file, even though it is no longer needed. If you just use a single -, then it is not included. *The write exits immediately after the file is written. There is currently no option to run as normal after the write. Although, it looks like the right hooks are there to add this in the future.
The changes turned out to be minimal. Because of the behavior above, just used -c for the config file and -w to write a config file.
ConfigArgParse does seem to be new-ish. Not clear how well it is maintained.
The tech for this exists in the script since #314 and there's the above issues to expose them in the web generator, so closing this here in favour of those.