diff --git a/src/prompts/list_prompt.rs b/src/prompts/list_prompt.rs index 92533f35..2191ce51 100644 --- a/src/prompts/list_prompt.rs +++ b/src/prompts/list_prompt.rs @@ -1,6 +1,6 @@ use inquire::validator::Validation; use inquire::Text; -use std::collections::{BTreeSet, HashSet}; +use std::collections::BTreeSet; use std::fmt::{Debug, Display}; use std::str::FromStr; @@ -15,13 +15,14 @@ where T: FromStr + ListPrompt + Ord, ::Err: Display + Debug + Sync + Send + 'static, { + const DELIMITERS: [char; 2] = [' ', ',']; let items = Text::new(T::MESSAGE) .with_help_message(T::HELP_MESSAGE) .with_validator(|input: &str| { let items = input - .split(|char: char| !char.is_alphanumeric()) + .split(|char| DELIMITERS.contains(&char)) .filter(|str| !str.is_empty()) - .collect::>(); + .collect::>(); let items_len = items.len(); if items_len > T::MAX_ITEMS as usize { return Ok(Validation::Invalid( @@ -33,14 +34,14 @@ where )); } for item in items { - if let Err(error) = T::from_str(input) { + if let Err(error) = T::from_str(item) { return Ok(Validation::Invalid(format!("{item}: {error}").into())); } } Ok(Validation::Valid) }) .prompt()? - .split(|char: char| !char.is_alphanumeric()) + .split(|char| DELIMITERS.contains(&char)) .filter_map(|str| T::from_str(str).ok()) .collect::>(); if items.is_empty() {