diff --git a/src/main.rs b/src/main.rs index b853aa7..50dbaa2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,9 @@ mod dirs; mod tui; -use std::fs; use std::io::Write; use std::path::{Path, PathBuf}; +use std::{fs, path}; use anyhow::{ensure, Result}; use clap::{Parser, Subcommand}; @@ -118,9 +118,9 @@ fn print_shell_integration(shell: &ShellType) { fn add_project

(projects: &mut Projects, path: P) -> Result<()> where - P: Into, + P: AsRef, { - let path = path.into(); + let path = path::absolute(path)?; ensure!(path.is_dir(), "Project path does not exists"); ensure!( @@ -130,6 +130,7 @@ where projects.list.push(path); write_projects_file(projects)?; + println!("Added {}", projects.list.last().unwrap().display()); Ok(()) } @@ -139,7 +140,7 @@ fn remove_project

(projects: &mut Projects, path: P) -> Result<()> where P: AsRef, { - let path = path.as_ref(); + let path = path::absolute(path)?; ensure!( projects.list.contains(&path.to_path_buf()), @@ -149,7 +150,7 @@ where let idx = projects.list.iter().enumerate().find_map( |(idx, elem)| { - if elem == path { + if elem == &path { Some(idx) } else { None