create-lamdera-app-rs 0.1.8

A CLI tool to scaffold Lamdera applications with Tailwind CSS, authentication, i18n, and testing
Documentation
use crate::args::{PackageManager, validate_project_name};
use crate::error::Result;
use dialoguer::{Confirm, Input, Select};

pub fn prompt_project_name() -> Result<String> {
    loop {
        let name: String = Input::new()
            .with_prompt("Project name")
            .interact_text()?;

        match validate_project_name(&name) {
            Ok(_) => return Ok(name),
            Err(e) => {
                println!("{}", e);
                continue;
            }
        }
    }
}

pub fn prompt_create_github() -> Result<bool> {
    Confirm::new()
        .with_prompt("Create GitHub repository?")
        .default(true)
        .interact()
        .map_err(Into::into)
}

pub fn prompt_repository_visibility() -> Result<bool> {
    let choices = vec!["Private", "Public"];
    let selection = Select::new()
        .with_prompt("Repository visibility")
        .items(&choices)
        .default(0)
        .interact()?;

    Ok(selection == 1) // true if Public
}

pub fn prompt_package_manager() -> Result<PackageManager> {
    let choices = vec!["npm", "bun"];
    let selection = Select::new()
        .with_prompt("Package manager")
        .items(&choices)
        .default(0)
        .interact()?;

    Ok(if selection == 1 {
        PackageManager::Bun
    } else {
        PackageManager::Npm
    })
}

pub fn prompt_boilerplate_type() -> Result<bool> {
    let choices = vec![
        "Full boilerplate (with counter/chat demos)",
        "Simple boilerplate (infrastructure only)",
    ];
    let selection = Select::new()
        .with_prompt("Boilerplate type")
        .items(&choices)
        .default(0)
        .interact()?;

    Ok(selection == 1) // true if Simple
}