From 70289215a7c75cc16d44ce4e74db26c8c1a40fa1 Mon Sep 17 00:00:00 2001 From: voidarc Date: Fri, 21 Aug 2026 16:47:13 +0100 Subject: [PATCH] made util function for finding files with index --- src/utils.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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) +}