From 78d2653d7971b76532e7aa5048505224fb55dfb7 Mon Sep 17 00:00:00 2001 From: arty Date: Fri, 5 Jul 2024 13:06:07 -0700 Subject: [PATCH] Ensure that we take an empty argument as a default when a default value exists --- src/classic/clvm_tools/comp_input.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/classic/clvm_tools/comp_input.rs b/src/classic/clvm_tools/comp_input.rs index 7ce810e0..448a1b52 100644 --- a/src/classic/clvm_tools/comp_input.rs +++ b/src/classic/clvm_tools/comp_input.rs @@ -59,7 +59,7 @@ pub fn parse_tool_input_sexp( ) -> Result { match parsed_args.get("hex") { Some(_) => { - let (path, use_sexp_text) = if let Some(r) = + let (path, sexp_text) = if let Some(r) = get_string_and_filename_with_default(parsed_args, argument, default_hex) { r @@ -67,6 +67,13 @@ pub fn parse_tool_input_sexp( return Err("missing argument {argument}".to_string()); }; + let use_sexp_text = + if sexp_text.is_empty() { + default_hex.unwrap_or_default() + } else { + &sexp_text + }.to_string(); + let sexp_serialized = Bytes::new_validated(Some(UnvalidatedBytesFromType::Hex(use_sexp_text.clone()))) .map_err(|e| format!("{e:?}"))?;