From 59c4020a01aa28b99d5a3ef472c0cf6bd0de8e34 Mon Sep 17 00:00:00 2001 From: gil Date: Mon, 3 Jun 2024 02:08:44 -0500 Subject: [PATCH] Add more todos, `ExportOptions` struct --- src/{manip.rs => list.rs} | 17 +++++++++++++++-- src/main.rs | 7 ++++--- src/parse.rs | 5 +++++ 3 files changed, 24 insertions(+), 5 deletions(-) rename src/{manip.rs => list.rs} (91%) create mode 100644 src/parse.rs diff --git a/src/manip.rs b/src/list.rs similarity index 91% rename from src/manip.rs rename to src/list.rs index 662b50b..6da8995 100644 --- a/src/manip.rs +++ b/src/list.rs @@ -82,7 +82,7 @@ pub struct MergedLimitList { } impl MergedLimitList { - pub fn new() -> Self { + pub fn default() -> Self { Self { hosts: HashMap::new(), trusts: (0, 0), @@ -139,9 +139,22 @@ impl MergedLimitList { } } +// TODO implement +pub struct ExportOptions { + pub export_format: String, // TODO custom enum for export formats = txt, csv, etc. + pub suspend_path: PathBuf, + pub suspend_thresholds: Vec, + + pub silence_path: PathBuf, + pub silence_thresholds: Vec, + + pub alphabetize: bool, + pub suppress_reviewables: bool, +} + pub fn alphabetize_lines(string: String) -> String { let mut v: Vec<&str> = string.lines().collect(); v.sort_by_key(|a| a.to_lowercase()); v.join("\n") + "\n" -} +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 59d50c1..1b520a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,11 @@ // src/main.rs mod cli; -mod manip; +mod list; +mod parse; use glob::glob; -use manip::{Limit, LimitList, MergedLimitList}; +use list::{Limit, LimitList, MergedLimitList}; fn main() -> std::io::Result<()> { env_logger::init(); // TODO add more logging & actual error handling @@ -14,7 +15,7 @@ fn main() -> std::io::Result<()> { // TODO parse config file if one is provided - let mut merged_list = MergedLimitList::new(); + let mut merged_list = MergedLimitList::default(); // Crawl /suspend for suspend lists -> glob pattern: "suspend/**/*.txt" { diff --git a/src/parse.rs b/src/parse.rs new file mode 100644 index 0000000..c5d56d4 --- /dev/null +++ b/src/parse.rs @@ -0,0 +1,5 @@ +// src/parser.rs + +// TODO FileParser trait: +// * fn read(pathbuf?) -> result +// * fn write(list, pathbuf) -> result<()> \ No newline at end of file