Skip to content

Commit

Permalink
Add some context to the [None] option when scaffolding a link-type
Browse files Browse the repository at this point in the history
  • Loading branch information
c12i committed Oct 15, 2024
1 parent ec56ad9 commit b534735
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/scaffold/entry_type/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ pub fn choose_reference_entry_hash(prompt: &str, recommended: bool) -> ScaffoldR
.items(&options.map(|(name, _)| name))
.interact()?;

Ok(options[selection].1)
let (_, value) = options[selection];

Ok(value)
}

pub fn get_or_choose_referenceable(
Expand Down Expand Up @@ -95,7 +97,11 @@ pub fn choose_optional_referenceable(
all_entries: &[EntryTypeReference],
prompt: &str,
) -> ScaffoldResult<Option<Referenceable>> {
inner_choose_referenceable(all_entries, prompt, Some(vec!["[None]"]))
inner_choose_referenceable(
all_entries,
prompt,
Some(vec!["[None] (Use this link to attach meta-data only)"]),
)
}

fn inner_choose_referenceable(
Expand Down Expand Up @@ -136,11 +142,11 @@ fn inner_choose_referenceable(
)?;
Ok(Some(Referenceable::ExternalHash { name }))
}
"[None]" => Ok(None),
entry_type if entry_type.starts_with("[None]") => Ok(None),
entry_type => Ok(Some(Referenceable::EntryType(EntryTypeReference {
entry_type: entry_type.to_owned(),
reference_entry_hash: choose_reference_entry_hash(
&String::from("Reference this entry type with its entry hash or its action hash?"),
"Reference this entry type with its entry hash or its action hash?",
all_entries[selection].reference_entry_hash,
)?,
}))),
Expand Down

0 comments on commit b534735

Please sign in to comment.