Skip to content

Commit

Permalink
Merge pull request #171 from c12i/fix-empty-list-of-items-given-to-se…
Browse files Browse the repository at this point in the history
…lect

Handle error creating linked `ActionHash` or `EntryHash` without previous entry-types existing
  • Loading branch information
c12i authored Jan 8, 2024
2 parents 1bd14e8 + 4b0092c commit e3c13d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ Add new entry definitions to your zome with:
let file_tree = load_directory_into_memory(&current_dir)?;
let template_file_tree = choose_or_get_template_file_tree(&file_tree, &template)?;

let name: String = match name {
let name = match name {
Some(n) => {
check_case(&n, "entry type name", Case::Snake)?;
n
Expand Down
1 change: 1 addition & 0 deletions src/scaffold/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl AppFileTree {
pub fn file_tree(self) -> FileTree {
self.file_tree
}

pub fn file_tree_ref<'a>(&'a self) -> &'a FileTree {
&self.file_tree
}
Expand Down
9 changes: 8 additions & 1 deletion src/scaffold/entry_type/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dialoguer::{theme::ColorfulTheme, Confirm, Select};
use regex::Regex;

use crate::{
error::ScaffoldResult,
error::{ScaffoldError, ScaffoldResult},
file_tree::{dir_content, FileTree},
scaffold::zome::ZomeFileTree,
utils::{check_case, input_with_case, input_with_case_and_initial_text},
Expand Down Expand Up @@ -261,6 +261,13 @@ pub fn choose_field(
));
}

if all_options.is_empty() {
return Err(ScaffoldError::NoEntryTypesDefFoundForIntegrityZome(
zome_file_tree.dna_file_tree.dna_manifest.name(),
zome_file_tree.zome_manifest.name.to_string(),
))
}

let selection = Select::with_theme(&ColorfulTheme::default())
.with_prompt(String::from("Which entry type is this field referring to?"))
.default(0)
Expand Down

0 comments on commit e3c13d6

Please sign in to comment.