add explicit separator default value

This commit is contained in:
Marcello 2024-02-14 23:42:27 +01:00
parent 246231332f
commit bf24de0d04
No known key found for this signature in database

View file

@ -32,8 +32,7 @@ fn main() -> Result<()> {
.with_context(|| format!("`{input}` does not contain valid JSON"))?; .with_context(|| format!("`{input}` does not contain valid JSON"))?;
let mut vars: Vec<EnvVar> = vec![]; let mut vars: Vec<EnvVar> = vec![];
let separator = args.separator.unwrap_or("__".to_string()); JsonParser::parse(&mut vars, "", &json, &args.separator);
JsonParser::parse(&mut vars, "", &json, &separator);
let environ = vars let environ = vars
.iter() .iter()
@ -70,9 +69,9 @@ struct Args {
#[arg(short, long, value_name = "FILE")] #[arg(short, long, value_name = "FILE")]
output: Option<String>, output: Option<String>,
/// Separator for nested keys, defaults to double underscore (__) /// Separator for nested keys
#[arg(short, long, value_name = "STRING")] #[arg(short, long, value_name = "STRING", default_value = "__")]
separator: Option<String>, separator: String,
} }
struct JsonParser; struct JsonParser;