diff --git a/src/utils.rs b/src/utils.rs index 1d71fe8..9197e89 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -3,6 +3,7 @@ use std::{ fs, io::{self, Write}, path::Path, + process, }; use xdg::BaseDirectories; @@ -118,3 +119,23 @@ pub fn match_file_name(file_name: &str, shelf: &mut Shelf) -> Result Result { + let index: usize = match file.parse::() { + Ok(index) => { + println!("path is: {}", &shelf.content[*&index]); + index + } + Err(_) => match match_file_name(&file, shelf) { + Ok(index) => { + println!("path is: {}", &shelf.content[*&index as usize]); + index + } + Err(e) => { + eprintln!("{e}"); + process::exit(1) + } + }, + }; + Ok(index) +}