You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Personally I would like to be able to easily print out my config in a bash format.
Then I could copy one of the config's env vars from my app's output, change the env var and restart my binary.
Others may want to output their config's env vars in a YAML-like syntax and change them in their kubernetes config.
To provide those use cases with a simple and straight-forward solution, I propose to add the following function to envy:
I really like this solution, because it is very flexible.
At the least this alternative should be a candidate to add in the future as well.
Implementing this function without using a std::vec::IntoIter is a bit awkward because the Serialize trait does not seem like it's designed for this kind of step-wise serialization to an Iterator.
Printing an Iterator<Item = Result<(String, String)>> similar to the example above is a bit more complicated:
for result in envy::to_iter(&Config::default())? {let(key, value) = result?;println!("{key}={value:?}");}
There's definitely an argument to keep envy as simple as possible.
I'm really curious, what other people think about this idea.
Maybe there are simpler solutions that I've overlooked.
The text was updated successfully, but these errors were encountered:
💡 Feature description
Personally I would like to be able to easily print out my config in a bash format.
Then I could copy one of the config's env vars from my app's output, change the env var and restart my binary.
Others may want to output their config's env vars in a YAML-like syntax and change them in their kubernetes config.
To provide those use cases with a simple and straight-forward solution, I propose to add the following function to envy:
💻 Basic example
Alternatives
Use std::fmt::Debug instead
This has the following downsides:
derive(Debug)
.With serde you could use
#[serde(skip_serializing)]
.Write a custom Serializer or
fn to_custom_format
for every format insteadI think for simple formats writing a Serializer is more complicated than a function using to_vec.
Add a
fn to_iter
insteadI really like this solution, because it is very flexible.
At the least this alternative should be a candidate to add in the future as well.
Implementing this function without using a
std::vec::IntoIter
is a bit awkward because the Serialize trait does not seem like it's designed for this kind of step-wise serialization to an Iterator.Printing an
Iterator<Item = Result<(String, String)>>
similar to the example above is a bit more complicated:or when ignoring Err values:
Not adding anything to envy
There's definitely an argument to keep envy as simple as possible.
I'm really curious, what other people think about this idea.
Maybe there are simpler solutions that I've overlooked.
The text was updated successfully, but these errors were encountered: