From c4e10d1a722997b6c0c2caac2f08c5dc044be5b2 Mon Sep 17 00:00:00 2001 From: lordofwizard Date: Thu, 17 Oct 2024 07:40:41 +0530 Subject: [PATCH] [FORMAT] Formated changes added --- src/run.rs | 2 +- src/setup.rs | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/run.rs b/src/run.rs index 2959751..b6b1e41 100644 --- a/src/run.rs +++ b/src/run.rs @@ -43,7 +43,7 @@ mod tests { assert!(true); } - /*Unused Test + /*Unused Test #[test] fn setup_available() { //setup(); diff --git a/src/setup.rs b/src/setup.rs index 48cbd53..0b6adf2 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -1,5 +1,8 @@ use std::{ - fs, io::{self, Write}, panic, path::Path + fs, + io::{self, Write}, + panic, + path::Path, }; pub fn setup() { let project_name = take_project_name(); @@ -14,7 +17,7 @@ fn take_project_name() -> String { io::stdout().flush().unwrap(); let mut project_name = String::new(); - + io::stdin() .read_line(&mut project_name) .expect("Failed to read input"); @@ -27,7 +30,7 @@ fn take_project_name() -> String { fn project_name_validator(project_name: &str) -> &str { // Trim leading and trailing whitespace from the input let trimmed_project_name = project_name.trim(); - + // Check for empty or spaces inside the project name if trimmed_project_name.is_empty() || project_name.contains(' ') { panic!("Invalid project name. Please enter only alphabetic characters or underscores, no numbers or whitespace."); @@ -37,7 +40,10 @@ fn project_name_validator(project_name: &str) -> &str { let cleaned_project_name = trimmed_project_name.trim_end_matches(|c| c == '\n' || c == '\r'); // Ensure the cleaned project name meets the criteria - if cleaned_project_name.chars().all(|c| c.is_alphabetic() || c == '_') { + if cleaned_project_name + .chars() + .all(|c| c.is_alphabetic() || c == '_') + { return cleaned_project_name; } else { panic!("Invalid project name. Please enter only alphabetic characters or underscores, no numbers or whitespace."); @@ -243,9 +249,9 @@ mod tests_for_directory_of_project { #[cfg(test)] mod tests_for_project_tree { use super::*; + use std::env; use std::fs; use std::path::Path; - use std::env; fn setup_tmp_directory() -> std::io::Result<()> { env::set_current_dir("/tmp") @@ -319,9 +325,9 @@ mod tests_for_project_tree { #[cfg(test)] mod tests_for_empty_config { use super::*; + use std::env; use std::fs; use std::path::Path; - use std::env; fn setup_tmp_directory() -> std::io::Result<()> { env::set_current_dir("/tmp") @@ -381,4 +387,4 @@ mod tests_for_empty_config { fs::remove_file(format!("{}/config.toml", project_name)).unwrap(); fs::remove_dir(project_name).unwrap(); } -} \ No newline at end of file +}