diff --git a/src/bin/drop.rs b/src/bin/drop.rs index 44f7897..8b1ed38 100644 --- a/src/bin/drop.rs +++ b/src/bin/drop.rs @@ -31,10 +31,10 @@ fn main() -> Result<()> { 4 => item::drop(&args[2], &args[1].as_str().replace("--slot=", ""), Path::new(&args[4]).to_path_buf())?, 3 => item::drop(&args[2], &args[1].as_str().replace("--slot=", ""), match env::current_dir() { Ok(dir) => dir, - Err(_) => bail!("❌ {}", "Vento was unable to detect your current directory. Have you configured your environment correctly?".red()) + Err(_) => bail!("{}", "Vento was unable to detect your current directory. Have you configured your environment correctly?".red()) })?, - 2 => bail!("❌ {}", "You need to specify a file".red()), - _ => bail!("❌ {}", "Too many arguments".red()), + 2 => bail!("{}", "You need to specify a file".red()), + _ => bail!("{}", "Too many arguments".red()), }; } else { match args[1].as_str() { @@ -43,19 +43,19 @@ fn main() -> Result<()> { 5 => item::drop(&args[3], &args[2], Path::new(&args[4]).to_path_buf())?, 4 => item::drop(&args[3], &args[2], match env::current_dir() { Ok(dir) => dir, - Err(_) => bail!("❌ {}", "Vento was unable to detect your current directory. Have you configured your environment correctly?".red()) + Err(_) => bail!("{}", "Vento was unable to detect your current directory. Have you configured your environment correctly?".red()) })?, - 3 => bail!("❌ {}", "You need to specify a file".red()), - 2 => bail!("❌ {}", "You need to specify a slot".red()), - _ => bail!("❌ {}", "Too many arguments".red()), + 3 => bail!("{}", "You need to specify a file".red()), + 2 => bail!("{}", "You need to specify a slot".red()), + _ => bail!("{}", "Too many arguments".red()), }, _ => match args.len() { 3 => item::drop(&args[1], &String::from("active"), Path::new(&args[2]).to_path_buf())?, 2 => item::drop(&args[1], &String::from("active"), match env::current_dir() { Ok(dir) => dir, - Err(_) => bail!("❌ {}", "Vento was unable to detect your current directory. Have you configured your environment correctly?".red()) + Err(_) => bail!("{}", "Vento was unable to detect your current directory. Have you configured your environment correctly?".red()) })?, - _ => bail!("❌ {}", "Too many arguments".red()), + _ => bail!("{}", "Too many arguments".red()), }, } } diff --git a/src/bin/take.rs b/src/bin/take.rs index 0736bf8..d226830 100644 --- a/src/bin/take.rs +++ b/src/bin/take.rs @@ -28,21 +28,21 @@ fn main() -> Result<()> { if args[1].contains("--slot=") { match args.len() { 3 => item::take(&args[2], &args[1].replace("--slot=", ""))?, - 2 => bail!("❌ {}", "You need to specify a file".red()), - _ => bail!("❌ {}", "Too many arguments".red()), + 2 => bail!("{}", "You need to specify a file".red()), + _ => bail!("{}", "Too many arguments".red()), }; } else { match args[1].as_str() { "--help" | "-h" => help::take()?, "-s" => match args.len() { 4 => item::take(&args[3], &args[2])?, - 3 => bail!("❌ {}", "You need to specify a file".red()), - 2 => bail!("❌ {}", "You need to specify a slot".red()), - _ => bail!("❌ {}", "Too many arguments".red()), + 3 => bail!("{}", "You need to specify a file".red()), + 2 => bail!("{}", "You need to specify a slot".red()), + _ => bail!("{}", "Too many arguments".red()), }, _ => match args.len() { 2 => item::take(&args[1], &String::from("active"))?, - _ => bail!("❌ {}", "Too many arguments".red()), + _ => bail!("{}", "Too many arguments".red()), }, } } diff --git a/src/bin/vento.rs b/src/bin/vento.rs index 50d790f..40beeee 100644 --- a/src/bin/vento.rs +++ b/src/bin/vento.rs @@ -30,7 +30,7 @@ fn main() -> Result<()> { match args.len() { 3 => inv::list(&args[1].replace("--slot=", ""), &args[2])?, 2 => inv::list(&args[1].replace("--slot=", ""), "")?, - _ => bail!("❌ {}", "Too many arguments".red()), + _ => bail!("{}", "Too many arguments".red()), }; } else { match args[1].as_str() { @@ -40,8 +40,8 @@ fn main() -> Result<()> { "-s" => match args.len() { 4 => inv::list(&args[2], &args[3])?, 3 => inv::list(&args[2], "")?, - 2 => bail!("❌ {}", "You need to specify a slot.".red()), - _ => bail!("❌ {}", "Too many arguments".red()), + 2 => bail!("{}", "You need to specify a slot.".red()), + _ => bail!("{}", "Too many arguments".red()), }, _ => inv::list("active", args[1].as_str())?, } diff --git a/src/common.rs b/src/common.rs index c9c758b..9cf8f46 100644 --- a/src/common.rs +++ b/src/common.rs @@ -29,7 +29,7 @@ pub fn env_config() -> Result> { _ => PathBuf::new(), }; if home == PathBuf::new() { - bail!("❌ {}", "Vento was unable to detect your home folder. Have you configured your environment correctly?".red()); + bail!("{}", "Vento was unable to detect your home folder. Have you configured your environment correctly?".red()); }; let vento_dir: PathBuf; let custom_dir = Path::new(&dir_config()?).to_path_buf(); diff --git a/src/inv.rs b/src/inv.rs index 55f2c8f..12dc58f 100644 --- a/src/inv.rs +++ b/src/inv.rs @@ -59,7 +59,7 @@ pub fn list(slot: &str, dir: &str) -> Result<()> { if !ventodir.is_dir() { bail!( - "❌ {}", + "{}", "Vento not initialized. Run \"vento -i\" to initialize Vento.".red() ); } @@ -69,7 +69,7 @@ pub fn list(slot: &str, dir: &str) -> Result<()> { } if dir.to_string().contains("..") { - bail!("❌ {}", "Cannot access parent.".red()); + bail!("{}", "Cannot access parent.".red()); } if slotdir.is_dir() { @@ -149,8 +149,8 @@ pub fn list(slot: &str, dir: &str) -> Result<()> { } } } else { - println!( - "❌ {}", + bail!( + "{}", format!( "No such slot or directory. Valid slots are {} and {}.", "active".green().bold(), @@ -171,7 +171,7 @@ pub fn switch() -> Result<()> { .iter() .collect(); - let rename_error = "❌ Vento was unable to switch slots. Try running vento init and try again"; + let rename_error = "Vento was unable to switch slots. Try running vento init and try again"; fs::rename(&active, &temp).context(rename_error)?; fs::rename(&inactive, &active).context(rename_error)?; @@ -186,7 +186,7 @@ fn create_slots() -> Result<()> { let active = &common::env_config()?[1]; let inactive = &common::env_config()?[2]; - let initialize_error = "❌ Vento was unable to initalize. Do you have the correct permissions"; + let initialize_error = "Vento was unable to initalize. Do you have the correct permissions?"; fs::create_dir_all(active).context(initialize_error)?; fs::create_dir_all(inactive).context(initialize_error)?; diff --git a/src/item.rs b/src/item.rs index 2f43e8b..f159bc1 100644 --- a/src/item.rs +++ b/src/item.rs @@ -36,17 +36,17 @@ pub fn take(file: &String, slot: &String) -> Result<()> { if Path::exists(&destpath) { bail!( - "❌ {}", + "{}", "A file with the same name already exists in your inventory!".red() ); } else if sourcepath.is_file() | sourcepath.is_symlink() { - fs::copy(&file, &destpath).expect("❌ Vento was unable to copy the file."); - fs::remove_file(&file).expect("❌ Vento was unable to remove the file."); + fs::copy(&file, &destpath).context("Vento was unable to copy the file.")?; + fs::remove_file(&file).context("Vento was unable to remove the file.")?; } else if sourcepath.is_dir() { let options = CopyOptions::new(); - move_dir(&file, &slotdir, &options).expect("❌ Vento was unable to move the directory."); + move_dir(&file, &slotdir, &options).context("Vento was unable to move the directory.")?; } else { - println!("❌ {}", "No such file or directory.".red()); + bail!("{}", "No such file or directory.".red()); } Ok(()) } @@ -69,17 +69,17 @@ pub fn drop(file: &String, slot: &String, dest: PathBuf) -> Result<()> { if Path::exists(&destpath) { // HAHA YANDEREDEV MOMENT. This checks what method to use for the file/directory the user has picked - bail!("❌ {}", "A file with the same name already exists in the destination! Try renaming it or dropping this file somewhere else.".red()); + bail!("{}", "A file with the same name already exists in the destination! Try renaming it or dropping this file somewhere else.".red()); } else if sourcepath.is_file() | sourcepath.is_symlink() { - fs::copy(&sourcepath, &destpath).context("❌ Vento was unable to copy the file.")?; - fs::remove_file(&sourcepath).context("❌ Vento was unable to remove the file.")?; + fs::copy(&sourcepath, &destpath).context("Vento was unable to copy the file.")?; + fs::remove_file(&sourcepath).context("Vento was unable to remove the file.")?; } else if sourcepath.is_dir() { let destpath: PathBuf = Path::new(&dest).to_path_buf(); let options = CopyOptions::new(); move_dir(&sourcepath, &destpath, &options) - .expect("❌ Vento was unable to move the directory."); + .context("Vento was unable to move the directory.")?; } else { - bail!("❌ {}", "No such file or directory.".red()); + bail!("{}", "No such file or directory.".red()); } Ok(()) }