Implement sequences feature v1.1.0

- Add -s/--sequence option to select transformation sequences
- Add -L flag to list all available sequences
- Implement 5 hardcoded sequences: default, lower, upper, minimal, utf-8
- Refactor clean_filename() to support sequence-based transformations
- Update all tests to pass sequence parameter (25 tests passing)
- Add 8 new integration tests for sequence functionality
- Update documentation (README, CHANGELOG, manpage)
- Update shell completions (bash, zsh, fish)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-02-10 18:38:23 +01:00
commit 2ec4d12d6c
12 changed files with 501 additions and 52 deletions

View file

@ -257,3 +257,135 @@ fn test_conf_option_missing_file() {
.failure()
.stderr(predicate::str::contains("nicht gefunden"));
}
#[test]
fn test_sequence_lower() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join("empty.toml");
fs::write(&config_file, "[replacements]\n").unwrap();
let file_path = temp_dir.path().join("Test File.txt");
fs::write(&file_path, "content").unwrap();
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("--conf")
.arg(&config_file)
.arg("-s")
.arg("lower")
.arg(temp_dir.path());
cmd.assert().success();
assert!(temp_dir.path().join("test_file.txt").exists());
}
#[test]
fn test_sequence_upper() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join("empty.toml");
fs::write(&config_file, "[replacements]\n").unwrap();
let file_path = temp_dir.path().join("test file.txt");
fs::write(&file_path, "content").unwrap();
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("--conf")
.arg(&config_file)
.arg("-s")
.arg("upper")
.arg(temp_dir.path());
cmd.assert().success();
assert!(temp_dir.path().join("TEST_FILE.TXT").exists());
}
#[test]
fn test_sequence_minimal() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join("empty.toml");
fs::write(&config_file, "[replacements]\n").unwrap();
let file_path = temp_dir.path().join("Müller Datei.txt");
fs::write(&file_path, "content").unwrap();
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("--conf")
.arg(&config_file)
.arg("-s")
.arg("minimal")
.arg(temp_dir.path());
cmd.assert().success();
// Umlaute bleiben erhalten, nur Leerzeichen ersetzt
assert!(temp_dir.path().join("Müller_Datei.txt").exists());
}
#[test]
fn test_sequence_utf8() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join("empty.toml");
fs::write(&config_file, "[replacements]\n").unwrap();
let file_path = temp_dir.path().join("schön (1).txt");
fs::write(&file_path, "content").unwrap();
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("--conf")
.arg(&config_file)
.arg("-s")
.arg("utf-8")
.arg(temp_dir.path());
cmd.assert().success();
// Umlaut bleibt, Klammern entfernt
assert!(temp_dir.path().join("schön_1.txt").exists());
}
#[test]
fn test_list_sequences() {
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("-L");
cmd.assert()
.success()
.stdout(predicate::str::contains("default"))
.stdout(predicate::str::contains("lower"))
.stdout(predicate::str::contains("upper"))
.stdout(predicate::str::contains("minimal"))
.stdout(predicate::str::contains("utf-8"));
}
#[test]
fn test_list_sequences_verbose() {
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("-L").arg("-v");
cmd.assert()
.success()
.stdout(predicate::str::contains("Umlauts → ASCII"))
.stdout(predicate::str::contains("Case transform"));
}
#[test]
fn test_invalid_sequence() {
let temp_dir = TempDir::new().unwrap();
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("-s").arg("invalid_seq").arg(temp_dir.path());
cmd.assert()
.failure()
.stderr(predicate::str::contains("Unbekannte Sequence"));
}
#[test]
fn test_sequence_default_explicit() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join("empty.toml");
fs::write(&config_file, "[replacements]\n").unwrap();
let file_path = temp_dir.path().join("Müller File.txt");
fs::write(&file_path, "content").unwrap();
let mut cmd = Command::new(cargo_bin!("ntu"));
cmd.arg("--conf")
.arg(&config_file)
.arg("-s")
.arg("default")
.arg(temp_dir.path());
cmd.assert().success();
// Default: Umlaut → ASCII
assert!(temp_dir.path().join("Mueller_File.txt").exists());
}