Add more todos, ExportOptions struct

This commit is contained in:
gil 2024-06-03 02:08:44 -05:00
parent 51db6ea06e
commit 59c4020a01
3 changed files with 24 additions and 5 deletions

View file

@ -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<u16>,
pub silence_path: PathBuf,
pub silence_thresholds: Vec<u16>,
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"
}
}

View file

@ -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"
{

5
src/parse.rs Normal file
View file

@ -0,0 +1,5 @@
// src/parser.rs
// TODO FileParser trait:
// * fn read(pathbuf?) -> result<list>
// * fn write(list, pathbuf) -> result<()>