I'm new to Rust. So bear with me...
I'm looking to have a "Global Configuration" construct that I can access from any place in the application I'm coding. Now, this could be achieve with a simple struct but I have a few requirements.
It is a commandline application. I'm using Clap. I'd like that the commandline arguments take superiority over the default configuration.
I'd like to read the environment variables and apply them as well. They do not take superiority over the arguments passed to the CLI.
Default configuration. That configuration is determined at execution time (it's not static).
How I think this will happen:
- Rust initialize the default configuration (some kind of a struct I think).
- Rust loads up the environment variables and replaces the default configuration where it applies.
- Rust does that too for the arguments passed to the CLI.
Anybody did something similar?