diff --git a/loco-new/src/wizard.rs b/loco-new/src/wizard.rs index ec313010a..3b3c52461 100644 --- a/loco-new/src/wizard.rs +++ b/loco-new/src/wizard.rs @@ -1,12 +1,13 @@ -//! This module provides interactive utilities for setting up application configurations -//! based on user input. +//! This module provides interactive utilities for setting up application +//! configurations based on user input. + +use dialoguer::{theme::ColorfulTheme, Confirm, Input, Select}; +use strum::IntoEnumIterator; use crate::{ wizard_opts::{self, AssetsOption, BackgroundOption, DBOption}, Error, }; -use dialoguer::{theme::ColorfulTheme, Confirm, Input, Select}; -use strum::IntoEnumIterator; /// Holds the user's configuration selections. pub struct Selections { @@ -32,8 +33,8 @@ impl Selections { } } -/// Prompts the user to enter an application name, with optional pre-set name input. -/// Validates the name to ensure compliance with required naming rules. +/// Prompts the user to enter an application name, with optional pre-set name +/// input. Validates the name to ensure compliance with required naming rules. /// Returns the validated name or an error if validation fails. /// /// # Errors @@ -58,8 +59,9 @@ pub fn app_name(name: Option) -> crate::Result { } } -/// Warns the user if the current directory is inside a Git repository and prompts -/// them to confirm whether they wish to proceed. If declined, an error is returned. +/// Warns the user if the current directory is inside a Git repository and +/// prompts them to confirm whether they wish to proceed. If declined, an error +/// is returned. /// /// # Errors /// when could not show user selection or user chose not continue @@ -150,7 +152,7 @@ pub fn start(args: &wizard_opts::ArgsPlaceholder) -> crate::Result { background: select_background(args)?, asset: AssetsOption::Clientside, }), - wizard_opts::Template::Advance => Ok(Selections { + wizard_opts::Template::Advanced => Ok(Selections { db: select_db(args)?, background: select_background(args)?, asset: select_asset(args)?, @@ -158,7 +160,8 @@ pub fn start(args: &wizard_opts::ArgsPlaceholder) -> crate::Result { } } -/// Prompts the user to select a database option if none is provided in the arguments. +/// Prompts the user to select a database option if none is provided in the +/// arguments. fn select_db(args: &wizard_opts::ArgsPlaceholder) -> crate::Result { let dboption = if let Some(dboption) = args.db.clone() { dboption @@ -171,7 +174,8 @@ fn select_db(args: &wizard_opts::ArgsPlaceholder) -> crate::Result { Ok(dboption) } -/// Prompts the user to select a background worker option if none is provided in the arguments. +/// Prompts the user to select a background worker option if none is provided in +/// the arguments. fn select_background(args: &wizard_opts::ArgsPlaceholder) -> crate::Result { let bgopt = if let Some(bgopt) = args.bg.clone() { bgopt @@ -184,7 +188,8 @@ fn select_background(args: &wizard_opts::ArgsPlaceholder) -> crate::Result crate::Result { let assetopt = if let Some(assetopt) = args.assets.clone() { assetopt diff --git a/loco-new/src/wizard_opts.rs b/loco-new/src/wizard_opts.rs index 5c5f19ce4..c6dd3e78d 100644 --- a/loco-new/src/wizard_opts.rs +++ b/loco-new/src/wizard_opts.rs @@ -8,16 +8,16 @@ use strum::{Display, EnumIter}; )] pub enum Template { #[default] - #[strum(to_string = "lightweight-service (minimal, only controllers and views)")] - Lightweight, - #[strum(to_string = "Rest API (with DB and user auth)")] - RestApi, #[strum(to_string = "Saas App with server side rendering")] SaasServerSideRendering, #[strum(to_string = "Saas App with client side rendering")] SaasClientSideRendering, - #[strum(to_string = "Advance")] - Advance, + #[strum(to_string = "Rest API (with DB and user auth)")] + RestApi, + #[strum(to_string = "lightweight-service (minimal, only controllers and views)")] + Lightweight, + #[strum(to_string = "Advanced")] + Advanced, } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] @@ -101,14 +101,14 @@ impl BackgroundOption { pub fn user_message(&self) -> Option { match self { Self::Queue => Some(format!( - "{}: You've selected `{}` for your background worker configuration (you should have a \ - Redis/valkey instance to connect to)", - "workers".underline(), - "queue".yellow() - )), + "{}: You've selected `{}` for your background worker configuration (you should \ + have a Redis/valkey instance to connect to)", + "workers".underline(), + "queue".yellow() + )), Self::Blocking => Some(format!( "{}: You've selected `{}` for your background worker configuration. Your workers \ - configuration will BLOCK REQUESTS until a task is done.", + configuration will BLOCK REQUESTS until a task is done.", "workers".underline(), "blocking".yellow() )), @@ -153,12 +153,12 @@ impl AssetsOption { pub fn user_message(&self) -> Option { match self { Self::Clientside => Some(format!( - "{}: You've selected `{}` for your asset serving configuration.\n\nNext step, build \ - your frontend:\n $ cd {}\n $ npm install && npm run build\n", - "assets".underline(), - "clientside".yellow(), - "frontend/".yellow() - )), + "{}: You've selected `{}` for your asset serving configuration.\n\nNext step, \ + build your frontend:\n $ cd {}\n $ npm install && npm run build\n", + "assets".underline(), + "clientside".yellow(), + "frontend/".yellow() + )), Self::Serverside | Self::None => None, } }