🔄 Update script metadata and add auto-hide feature in tree-rs

解释:
- `script-meta-v2.json` 和 `script-meta.json` 文件中的脚本长度、SHA256 哈希值和更新时间被修改,表明脚本内容发生了变化。
- `tree-rs/src/main.rs` 中新增了 `--auto-hide` 参数及其逻辑,用于自动隐藏特定目录(如 `target`, `build`, `node_modules`),并对相关代码进行了调整。
- 这些变更主要涉及功能更新和元数据同步,因此用 🔄 表示更新。
This commit is contained in:
2026-04-18 09:06:51 +08:00
parent 391d4f9a46
commit 1fea5c81c4
3 changed files with 29 additions and 11 deletions

View File

@@ -154,11 +154,11 @@
},
"tree.rs": {
"script_name": "tree.rs",
"script_length": 5396,
"script_sha256": "9f4f662900f77016545552427d5cb0c45e211e51ccc37f9819d6be4f08fed364",
"script_length": 5878,
"script_sha256": "5bb247e793363bb839b535a1bacd6d52ad785b802b230fe20586048e298b7439",
"script_full_url": "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/tree-rs/src/main.rs",
"publish_time": 1776447368459,
"update_time": 1776447368459
"update_time": 1776474400469
},
"xattr.rs": {
"script_name": "xattr.rs",

View File

@@ -91,8 +91,8 @@
},
"tree-rs": {
"script_name": "tree-rs",
"script_length": 5396,
"script_sha256": "9f4f662900f77016545552427d5cb0c45e211e51ccc37f9819d6be4f08fed364"
"script_length": 5878,
"script_sha256": "5bb247e793363bb839b535a1bacd6d52ad785b802b230fe20586048e298b7439"
},
"xattr-rs": {
"script_name": "xattr-rs",

View File

@@ -30,6 +30,9 @@ struct Args {
#[arg(long = "hide-dots", help = "Hide directories/files starting with a dot")]
hide_dots: bool,
#[arg(short = 'A', long = "auto-hide", help = "Hide .*, target, build, node_modules")]
auto_hide: bool,
#[arg(long = "hide", help = "Hide entries matching this name")]
hide: Vec<String>,
}
@@ -43,6 +46,18 @@ fn main() {
std::process::exit(1);
}
let auto_hide_patterns: Vec<String> = if args.auto_hide {
vec![
"target".to_string(),
"build".to_string(),
"node_modules".to_string(),
]
} else {
vec![]
};
let effective_hide_dots = args.hide_dots || args.auto_hide;
print_tree(
&path,
"",
@@ -52,8 +67,8 @@ fn main() {
args.depth,
args.human_readable,
args.no_color,
args.hide_dots,
args.hide.clone(),
effective_hide_dots,
auto_hide_patterns,
);
}
@@ -108,8 +123,11 @@ fn print_tree(
let human_readable = human_readable;
let mut entries: Vec<_> = fs::read_dir(path)
.unwrap_or_else(|e| panic!("Failed to read directory {:?}: {}", path, e))
let Ok(read_dir) = fs::read_dir(path) else {
eprintln!("Warning: Cannot read directory {:?}: Operation not permitted", path);
return;
};
let mut entries: Vec<_> = read_dir
.filter_map(|e| e.ok())
.filter(|e| {
let binding = e.file_name();
@@ -204,5 +222,5 @@ fn format_size(bytes: u64, no_color: bool) -> String {
}
}
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260418T013425+08:00.MEQCIBLXDlWGN9mmf8L/gXhw
// 92hRbs/GxAezQk646+N4Ho7OAiBAER2l2R1mPi00O51Ns00QIQN+WgAFD+RTyCnc8nbefw==
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260418T090515+08:00.MEYCIQCr9lu4Bztm56IuzTv0
// 11Egh7Qjmrfd3guWe70TIQhGzAIhAKaD5nY/hdLOKP06/o40saqscNmAKppvmv1kvBV631WU