From bf24de0d04ceef8808d40b2bcac15880e3871de5 Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Wed, 14 Feb 2024 23:42:27 +0100 Subject: [PATCH] add explicit separator default value --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9e2dc8d..18eac6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,8 +32,7 @@ fn main() -> Result<()> { .with_context(|| format!("`{input}` does not contain valid JSON"))?; let mut vars: Vec = vec![]; - let separator = args.separator.unwrap_or("__".to_string()); - JsonParser::parse(&mut vars, "", &json, &separator); + JsonParser::parse(&mut vars, "", &json, &args.separator); let environ = vars .iter() @@ -70,9 +69,9 @@ struct Args { #[arg(short, long, value_name = "FILE")] output: Option, - /// Separator for nested keys, defaults to double underscore (__) - #[arg(short, long, value_name = "STRING")] - separator: Option, + /// Separator for nested keys + #[arg(short, long, value_name = "STRING", default_value = "__")] + separator: String, } struct JsonParser;