Unify command line arguments with environment variables & config file #192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
to:
cc: @subspacecommunity/subspace-maintainers
related to:
resolves:
Background
We have some parameters which are passed on the command line and some which are read from environment variable.
And we have to know which is which. There is also no centralized location where all the start up config is documented.
This PR uses the Cobra library in conjunction with the Viper library to unify all of our startup configuration.
It still does not support all of the configuration from the command line (it's too much). But anything that can be configured from the command line can be configured instead from either a config file or an environment variable. Or a combination of all of these.
I've taken care to keep all environment variables and command line parameters as they were. But this PR is nonetheless a breaking change. Go cli library uses one dash for options, wherein Cobra, like other unix tools, uses double dash for options.
Testing
I've added some basic tests.