rust-cli/confy

Add `load_or_die` feature

sagoez opened this issue · 4 comments

sagoez commented

Is there any chance to create a load_or_die feature such that application don't start if not able to find configuration file? I'd be happy to implement this given the opportunity.

If you're using anyhow for example, you can do this:

#[derive(Default, Serialize, Deserialize)]
struct MyConfig {}

fn main() -> Result<(), anyhow::Error> {
    let cfg: MyConfig = confy::load("my-app-name", None)?;
    Ok(())
}

(Example partly taken from confy::load)

Does this solve your usecase?

sagoez commented

Hey. it does! Appreciate it!

You're welcome! 👍