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 aconfiguration
struct with with a string tacked on for theConfigPath
. - Splitting
addFlags(config *configuration)
intoparseFlags() startupFlags
andaddFlags(flags startupFlags, config *configuration)
.-
parseFlags
simply reads in the flags so we knowConfigPath
ahead of loading the config file -
addFlags
overwrites any values in the config with those passed in as flags
-
- Passing
ConfigPath
toloadConfigs
- 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.