-Merge branch 'bugfix/ignore'
This commit is contained in:
Adam Skotarczak 2025-05-24 03:24:34 +02:00
commit f80f6ac707
Signed by: realAscot
GPG Key ID: 4CB9B8D93A96A538
10 changed files with 62 additions and 18 deletions

14
.gitignore vendored
View File

@ -19,3 +19,17 @@ desktop.ini
# Releases (realAscot)
releases/**
bin/**
# Misc
*zip
*.tar.gz
*.tar.xz
*.tar.bz2
*.tar.lz

View File

@ -1,5 +1,11 @@
# Changelog treeScanner (Rust)
- **2025-05-24 - v1.0.1**
- **Bugfix:**
- [x] Parameter werden nun richtig geparst, auch `-x ./fu/,./bla` statt bisher nur `-x fu,bla`
---
- **2025-05-17 - v1.0.0**
- **Geändert:**
- [x] Komplette Neuumsetzung des TreeScanner-Tools in Rust

2
Cargo.lock generated
View File

@ -458,7 +458,7 @@ checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
[[package]]
name = "treescanner"
version = "1.0.0"
version = "1.0.1"
dependencies = [
"clap",
"dirs",

View File

@ -1,6 +1,6 @@
[package]
name = "treescanner"
version = "1.0.0"
version = "1.0.1"
edition = "2024"
[package.metadata.winres]

View File

@ -28,8 +28,9 @@ Der original treeScanner in Python ist unter <https://github.com/realAscot/treeS
- [🔍 Ort](#-ort)
- [📘 Format](#-format)
- [📝 Format (.toml)](#-format-toml)
- [Build](#build)
- [Lizenz](#lizenz)
- [Eingesetzte Libraries (MIT-kompatibel):](#eingesetzte-libraries-mit-kompatibel)
- [Eingesetzte Libraries (MIT-kompatibel)](#eingesetzte-libraries-mit-kompatibel)
- [💬 Kontakt](#-kontakt)
---
@ -180,11 +181,15 @@ align_comments = false
---
## Build
---
## Lizenz
Dieses Projekt steht unter der [MIT-Lizenz](./LICENSE).
### Eingesetzte Libraries (MIT-kompatibel):
### Eingesetzte Libraries (MIT-kompatibel)
| Crate | Lizenz |
|-----------------|------------|

View File

@ -1 +1 @@
1.0.0
1.0.1

View File

@ -3,7 +3,7 @@
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
FILEVERSION 1,0,1,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
@ -17,11 +17,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "ionivation.com"
VALUE "FileDescription", "CLI Verzeichnisscanner"
VALUE "FileVersion", "1.0.0.0"
VALUE "FileVersion", "1.0.1.0"
VALUE "InternalName", "treescanner"
VALUE "OriginalFilename", "treescanner.exe"
VALUE "ProductName", "CLI Treescanner"
VALUE "ProductVersion", "1.0.0"
VALUE "ProductVersion", "1.0.1"
VALUE "LegalCopyright", "(C) 2025 Adam Skotarczak"
END
END

View File

@ -54,17 +54,26 @@ impl TreeBuilder {
let mut folders = vec![];
let mut files = vec![];
for entry in entries {
let path = entry.path();
let file_name = entry.file_name().into_string().unwrap_or_default();
if entry.path().is_dir() {
if !self.config.ignored_dirs.contains(&file_name) {
folders.push((file_name, entry.path()));
if path.is_dir() {
if let Some(dir_name) = path.file_name().and_then(|s| s.to_str()) {
if self.config.ignored_dirs.iter().any(|ex| ex == dir_name) {
continue;
}
}
folders.push((file_name, path));
} else {
files.push(file_name);
}
}
for (idx, (name, path)) in folders.iter().enumerate() {
self.folder_count += 1;
let connector = if idx < folders.len() - 1 || !files.is_empty() { "├── " } else { "└── " };

View File

@ -42,7 +42,7 @@ pub struct CliArgs {
pub output: Option<PathBuf>,
/// Nur in Konsole anzeigen, keine Ausgabedatei speichern
#[arg(long)]
#[arg(short = 'i', long)]
pub viewonly: bool,
/// Debug-Modus aktivieren

View File

@ -16,6 +16,15 @@ fn view_timer(timer: &Instant) {
println!("\n⏱️ Gesamtlaufzeit des Scans: {:.2?}", timer.elapsed());
}
// Hilfsfunktion zur Pfad-Normalisierung
fn normalize_ignore_entry(s: &str) -> String {
s.trim_start_matches("./")
.trim_start_matches(".\\")
.trim_end_matches('/')
.trim_end_matches('\\')
.to_string()
}
fn main() {
init_logger();
let args = CliArgs::parse();
@ -34,6 +43,12 @@ fn main() {
}
}
let ignored_dirs: Vec<String> = match (!args.ignore.is_empty(), file_config.ignore) {
(true, _) => args.ignore.iter().map(|s| normalize_ignore_entry(s)).collect(),
(false, Some(set)) => set.into_iter().map(|s| normalize_ignore_entry(&s)).collect(),
(false, None) => vec![],
};
let config = TreeBuilderConfig {
root_path: args.root_path.clone(),
max_depth: args.max_depth.or(file_config.max_depth),
@ -42,12 +57,7 @@ fn main() {
} else {
file_config.max_files_per_dir.unwrap_or(100)
},
// Ignorierte Verzeichnisse: CLI hat Vorrang, dann Config, sonst leer
ignored_dirs: match (!args.ignore.is_empty(), file_config.ignore) {
(true, _) => args.ignore,
(false, Some(set)) => set.into_iter().collect(),
(false, None) => vec![],
},
ignored_dirs,
folder_icon: "📁".to_string(),
file_icon: "📄".to_string(),
align_comments: args.align_comments,