This commit is contained in:
Bel LaPointe
2025-11-11 11:29:04 -07:00
parent 5d2441ce0c
commit 7d36455bad
3 changed files with 129 additions and 2 deletions

View File

@@ -6,7 +6,6 @@ use std::io::{BufRead, Read, Write};
fn main() {
let flags = Flags::new().expect("failed to flags");
let files = flags.files().expect("failed to files");
assert!(files.files.len() > 0, "no files");
if !flags.dry_run {
for file in files.files.iter() {
@@ -82,16 +81,38 @@ impl Flags {
.filter(|x| x.is_ok())
.map(|x| x.unwrap())
.filter(|x| x.metadata().unwrap().is_file())
// TODO filter out hidden files
.map(|x| x.path().display().to_string())
.filter(|x| !x.contains("/."))
.collect()),
Err(msg) => Err(format!("failed to read {}: {}", self.path.clone(), msg)),
},
}?;
assert!(files.len() > 0, "no files");
Ok(Files::new(&files))
}
}
#[cfg(test)]
mod test_flags {
use super::*;
#[test]
fn test_flags_files_unhidden_only() {
let d = tempdir::TempDir::new("").unwrap();
std::fs::File::create(d.path().join("plain")).unwrap();
std::fs::File::create(d.path().join(".hidden")).unwrap();
let flags = Flags {
path: d.path().to_str().unwrap().to_string(),
add: None,
edit: false,
dry_run: true,
};
let files = flags.files().expect("failed to files from dir");
assert_eq!(1, files.files.len());
}
}
#[derive(Debug, Clone)]
struct Files {
files: Vec<File>,
@@ -201,6 +222,16 @@ impl File {
}
}
#[cfg(test)]
mod test_file {
use super::*;
#[test]
fn test_file() {
assert!(false, "not impl");
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
struct Delta {
ts: u64,
@@ -307,3 +338,13 @@ impl Events {
}
}
}
#[cfg(test)]
mod test_events {
use super::*;
#[test]
fn test_events() {
assert!(false, "not impl");
}
}