added fun colors!

currently added some green for the initialization
and red for errors, output color will be added
soon!
This commit is contained in:
Pyro57000
2025-05-28 12:59:39 -05:00
parent 6959e77d57
commit 249ecc786d
13 changed files with 190 additions and 129 deletions

View File

@@ -8,6 +8,8 @@ use std::process::Command;
use std::thread;
use std::time::Duration;
use std::str::FromStr;
use colored::Colorize;
use crate::get_user_input;
use crate::Project;
use crate::box_controls::make_box;
@@ -291,7 +293,7 @@ pub fn remove_project(projects: &mut Vec<Project>, config_path: &PathBuf){
}
}
pub fn get_projects(config_path: &PathBuf, show: bool) -> Vec<Project>{
pub fn get_projects(config_path: &PathBuf, show: bool) -> Option<Vec<Project>>{
let mut mut_config_path = config_path.clone();
mut_config_path.pop();
mut_config_path.push("projects.conf");
@@ -301,11 +303,18 @@ pub fn get_projects(config_path: &PathBuf, show: bool) -> Vec<Project>{
let bkup_result = fs::copy(&mut_config_path, &bkup_config_path);
if bkup_result.is_err(){
let error = bkup_result.err().unwrap();
println!("error backing up the projects.conf file!");
println!("error: {}", error);
println!("{}","error backing up the projects.conf file!".red());
println!("{}", error.to_string().red());
}
let mut projects = Vec::new();
let projects_string = fs::read_to_string(mut_config_path).expect("error reading projects file");
let projects_string_res = fs::read_to_string(mut_config_path);
if projects_string_res.is_err(){
let error = projects_string_res.err().unwrap();
println!("{}", "Error Loading Project!".red());
println!("{}", error.to_string().red());
return None;
}
let projects_string = projects_string_res.unwrap();
let project_lines:Vec<&str> = projects_string.split("\n").collect();
let mut first = 0;
let mut already_active = false;
@@ -338,13 +347,13 @@ pub fn get_projects(config_path: &PathBuf, show: bool) -> Vec<Project>{
let project_stage = settings[6].to_owned();
let new_project = Project{customer: customer, project_name: project, files_folder: project_folder, notes_folder: notes_folder, active: active, id: first, boxname: boxname, stage: project_stage};
if show{
println!("{} {} LOADED!", &new_project.customer, &new_project.project_name);
println!("{} {} {}", &new_project.customer, &new_project.project_name, "LOADED!".green());
}
projects.push(new_project);
}
}
}
return projects
return Some(projects)
}
pub fn print_upcoming_projects(projects: &Vec<Project>){