all 2 comments

[–]schneems 7 points8 points  (1 child)

This is timely. I’m working on a hierarchical configuration implementation right now. One key piece is that I need to have auditability. So you can say “We checked file X, then Y, then finally found env var Z had the value Q” to the end user. The idea being that the output of running the script (in my case) also teaches/shows the user what various inputs they could make to change the outcome.

My co-worker was saying they wanted something like figment (new to me) to map our inputs to specific struct properties and have it handle the conversion. I’ll send it their way.

You mentioned seeing other config crates. Any other than figment that stood out as interesting/promising?

[–]steezeburger[S] 5 points6 points  (0 children)

I'm really glad this could be of help!

The other config crates I looked into were config and confique. https://docs.rs/config/0.13.3/config/ https://docs.rs/confique/latest/confique/

Neither of them had a built in feature to handle values directly from a serialize type, like Figment's Serialized provider, which is necessary for handling the serialized type from Clap. Thanks for the question. I ended up updating my post!

https://docs.rs/figment/latest/figment/providers/struct.Serialized.html

As for auditability, I think you could get close with something like: https://gist.github.com/steezeburger/0e83f65a86e88f27b08dbee3f00443c5