subspacecommunity / subspace

A fork of the simple WireGuard VPN server GUI community maintained
MIT License
1.8k stars 131 forks source link

Unify command line arguments with environment variables & config file #192

Open dovreshef opened 3 years ago

dovreshef commented 3 years ago

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.

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information