Skip to content

Continue parsing for more missing required values #45

Open
@hbobenicio

Description

💡 Feature description

Continue parsing for more missing required values (instead stopping at the first one).

😍 Motivation

This can provide more information to the user/devops/developer in order to setup all missing values at once (instead of one by one).

💻 Basic example

Today, this:

use serde::Deserialize;

#[derive(Deserialize, Debug)]
struct Config {
    host: String,
    port: String,
}

fn main() {
    match envy::prefixed("APP_").from_env::<Config>() {
        Ok(config) => println!("{:#?}", config),
        Err(err) => {
            eprintln!("error: {:#?}", err);
            std::process::exit(1);
        }
    }
}

running with:

cargo run

outputs this:

error: MissingValue(
    "host",
)

The desired behaviour would output this instead:

error: MissingValues(
    [
        "host", // Or even better: "APP_HOST", considering prefix
        "port" // Or even better: "APP_PORT", considering prefix
    ]
)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions