advent-of-code-downloader
advent-of-code-downloader copied to clipboard
feat: adding `config-path` flag
This change adds a config-path parameter to the program that allows for a custom config file path instead of just the current or home directory. A passed in config file will cause the program to skip loading files in either the current or home directory. Other config flags passed in still take priority over values in the custom config.
This was accomplished by:
- Creating
startupFlags, which is just aconfigurationstruct with with a string tacked on for theConfigPath. - Splitting
addFlags(config *configuration)intoparseFlags() startupFlagsandaddFlags(flags startupFlags, config *configuration).parseFlagssimply reads in the flags so we knowConfigPathahead of loading the config fileaddFlagsoverwrites any values in the config with those passed in as flags
- Passing
ConfigPathtoloadConfigs- As mentioned before, passed in config takes priority over files in
~and.
- As mentioned before, passed in config takes priority over files in
I also did a small refactor of the flag parsing, changing from using flags.String across the board to flags.StringVar and flags.IntVar to avoid additional conversion from string to int. I will change this back if there are strong opinions about the previous parsing method.