From cbbe17e556c29e2fe69393bff9e694efe09410f3 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 2 Dec 2025 16:42:22 +0800 Subject: Add debug glob command for testing file matching The new `jv _glob` command allows testing glob patterns against both local files and sheet contents. It helps verify how the globber matches files in different contexts. --- src/utils/globber.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/utils/globber.rs') diff --git a/src/utils/globber.rs b/src/utils/globber.rs index 8edcfa1..1f7b83e 100644 --- a/src/utils/globber.rs +++ b/src/utils/globber.rs @@ -49,6 +49,8 @@ impl Globber { let pattern = if pattern.is_empty() { "*".to_string() + } else if pattern == "." { + "*".to_string() } else if pattern.ends_with(SPLIT_STR) { format!("{}*", pattern) } else { @@ -160,11 +162,33 @@ impl> From for Globber { } } +#[derive(Debug, Clone, Hash)] pub enum GlobItem { File(String), Directory(String), } +impl PartialEq for GlobItem { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (GlobItem::File(a), GlobItem::File(b)) => a == b, + (GlobItem::Directory(a), GlobItem::Directory(b)) => a == b, + _ => false, + } + } +} + +impl std::fmt::Display for GlobItem { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GlobItem::File(name) => write!(f, "{}", name), + GlobItem::Directory(name) => write!(f, "{}", name), + } + } +} + +impl Eq for GlobItem {} + pub mod constants { use std::{env::current_dir, path::PathBuf}; -- cgit