better print of search by word

This commit is contained in:
Volodymyr Patuta 2020-11-29 14:59:36 +01:00
parent 8210cb37aa
commit ca1c2005ea
1 changed files with 8 additions and 1 deletions

View File

@ -120,6 +120,13 @@ pub fn modify(header: &str) -> Result<()> {
Ok(()) Ok(())
} }
fn print_path(path: String) {
let off = path.find(".rnote/").unwrap_or(path.len()) + 7;
let mut path = path;
path.drain(..off);
println!("{}", path);
}
pub fn search_by_word(word: &str) -> Result<()> { pub fn search_by_word(word: &str) -> Result<()> {
extern crate fstream; extern crate fstream;
let path = get_base_path()?; let path = get_base_path()?;
@ -134,7 +141,7 @@ pub fn search_by_word(word: &str) -> Result<()> {
if b { if b {
let path = file.path().to_str().unwrap_or(""); let path = file.path().to_str().unwrap_or("");
if !path.is_empty() { if !path.is_empty() {
println!("{}", path); print_path(path.to_owned());
} }
} }
} }