Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions opstack/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,22 @@ impl Config {
match config_res {
Ok(config) => config,
Err(err) => {
let print_field_help = |field: &str| {
println!("\n\ttry supplying the proper command line argument: --{field}");
println!("\talternatively, you can add the field to your helios.toml file");
println!("\nfor more information, check the github README");
};

match err.kind {
figment::error::Kind::MissingField(field) => {
let field = field.replace('_', "-");
println!("\x1b[91merror\x1b[0m: missing configuration field: {field}");
println!("\n\ttry supplying the proper command line argument: --{field}");
println!("\talternatively, you can add the field to your helios.toml file");
println!("\nfor more information, check the github README");
print_field_help(&field);
}
figment::error::Kind::InvalidType(_, _) => {
let field = err.path.join(".").replace("_", "-");
println!("\x1b[91merror\x1b[0m: invalid configuration field: {field}");
println!("\n\ttry supplying the proper command line argument: --{field}");
println!("\talternatively, you can add the field to your helios.toml file");
println!("\nfor more information, check the github README");
print_field_help(&field);
}
_ => println!("cannot parse configuration: {err}"),
}
Expand Down