summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-12-02 16:42:22 +0800
committer魏曹先生 <1992414357@qq.com>2025-12-02 16:42:22 +0800
commitcbbe17e556c29e2fe69393bff9e694efe09410f3 (patch)
tree438ddd29d94fca3bfda50ffe847a0184817b04ea /src/utils
parent899e109f6ef3a32c25f75aec5690bb800c3466ac (diff)
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.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/globber.rs24
1 files changed, 24 insertions, 0 deletions
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<T: AsRef<str>> From<T> 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};