use anyhow::Result;
use dialoguer::{Confirm, Select, theme::ColorfulTheme};
pub enum TemplateChoice {
Minimum,
Tutorial,
}
pub fn choose_template() -> Result<TemplateChoice> {
let choices = &[
"Minimum - Skeleton with a layout and landing page",
"Tutorial - Guided tutorial with 10 interactive lessons",
];
println!();
let selection = Select::with_theme(&ColorfulTheme::default())
.with_prompt("Choose a template")
.items(choices)
.default(0)
.interact()?;
Ok(match selection {
0 => TemplateChoice::Minimum,
_ => TemplateChoice::Tutorial,
})
}
pub fn confirm_overwrite(name: &str) -> Result<bool> {
Confirm::with_theme(&ColorfulTheme::default())
.with_prompt(format!("Directory '{}' already exists. Overwrite?", name))
.default(false)
.interact()
.map_err(Into::into)
}