use dialoguer::{theme::ColorfulTheme, Select}; use std::str::FromStr; use strum::IntoEnumIterator; pub fn choose_enum() -> T where T: IntoEnumIterator + FromStr + ToString + Clone + 'static, ::Err: std::fmt::Debug, { // Choose template let template_selections: Vec = T::iter().map(|x| x.to_string()).collect(); let template = Select::with_theme(&ColorfulTheme::default()) .with_prompt("Template?") .default(0) .items(&template_selections[..]) .interact() .unwrap(); T::from_str(&template_selections[template]).unwrap() }