Skip to content

Commit

Permalink
Ensure that we take an empty argument as a default when a default val…
Browse files Browse the repository at this point in the history
…ue exists
  • Loading branch information
prozacchiwawa committed Jul 5, 2024
1 parent 3e16cb2 commit 78d2653
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/classic/clvm_tools/comp_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ pub fn parse_tool_input_sexp(
) -> Result<ParsedInputPathOrCode, String> {
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
} else {
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:?}"))?;
Expand Down

0 comments on commit 78d2653

Please sign in to comment.