Add clap, relocate test blocklists
This commit is contained in:
parent
acda290c4b
commit
1091399fec
88
Cargo.lock
generated
88
Cargo.lock
generated
|
@ -60,6 +60,46 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.1"
|
||||
|
@ -93,10 +133,17 @@ dependencies = [
|
|||
name = "fediloom"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
|
@ -121,6 +168,24 @@ version = "2.7.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.4"
|
||||
|
@ -150,6 +215,29 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
|
|
|
@ -4,5 +4,6 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.4", features = ["derive"] }
|
||||
env_logger = "0.11.3"
|
||||
log = "0.4.21"
|
||||
|
|
|
@ -9,4 +9,4 @@ Goal - a commandline-based tool for creating blocklists for ActivityPub software
|
|||
- [ ] Use URLs as sources
|
||||
- [ ] Directly request lists from API endpoints
|
||||
- [ ] Create tiered or thresholded lists
|
||||
- [ ] Support CSV and JSON1
|
||||
- [ ] Support CSV and JSON
|
15
src/main.rs
15
src/main.rs
|
@ -3,9 +3,20 @@
|
|||
mod manip;
|
||||
mod tests;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
// TODO inputs
|
||||
// TODO outputs
|
||||
// TODO cfg file (TOML)
|
||||
// TODO options
|
||||
// TODO verbose mode
|
||||
//
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
// TODO argument parsing
|
||||
// TODO argument parsing - IN PROGRESS
|
||||
// TODO logging
|
||||
// TODO config file
|
||||
}
|
|
@ -138,10 +138,7 @@ impl ModMap {
|
|||
}
|
||||
|
||||
pub fn alphabetize_lines(string: String) -> String {
|
||||
let mut v = string
|
||||
.lines()
|
||||
.map(|literal| literal.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
let mut v = string.lines().collect::<Vec<&str>>();
|
||||
v.sort_by_key(|a| a.to_lowercase());
|
||||
|
||||
v.join("\n") + "\n"
|
||||
|
|
|
@ -80,8 +80,8 @@ fn modsource_from_map_and_trust() {
|
|||
#[test]
|
||||
fn modsource_from_file() {
|
||||
let mut src = ModSource::default();
|
||||
src.import_file("example_blocklist1.txt", ModAction::Block)
|
||||
.import_file("example_mutelist1.txt", ModAction::Silence);
|
||||
src.import_file("test/example_blocklist.txt", ModAction::Block)
|
||||
.import_file("test/example_mutelist.txt", ModAction::Silence);
|
||||
|
||||
let test_src = ModSource::from(HashMap::from([
|
||||
(String::from("example.com"), ModAction::Block),
|
||||
|
@ -103,8 +103,8 @@ fn modmap_from_modsource() {
|
|||
]));
|
||||
|
||||
let mut src2 = ModSource::default();
|
||||
src2.import_file("example_blocklist1.txt", ModAction::Block)
|
||||
.import_file("example_mutelist1.txt", ModAction::Silence);
|
||||
src2.import_file("test/example_blocklist.txt", ModAction::Block)
|
||||
.import_file("test/example_mutelist.txt", ModAction::Silence);
|
||||
|
||||
ml.add_source(src1).add_source(src2);
|
||||
|
||||
|
@ -166,8 +166,8 @@ fn modmap_export_txt() {
|
|||
]));
|
||||
|
||||
let mut src2 = ModSource::default();
|
||||
src2.import_file("example_blocklist1.txt", ModAction::Block)
|
||||
.import_file("example_mutelist1.txt", ModAction::Silence);
|
||||
src2.import_file("test/example_blocklist.txt", ModAction::Block)
|
||||
.import_file("test/example_mutelist.txt", ModAction::Silence);
|
||||
|
||||
let src3 = ModSource::build(
|
||||
HashMap::from([
|
||||
|
@ -190,11 +190,11 @@ fn modmap_export_txt() {
|
|||
.add_source(src3)
|
||||
.add_source(src4);
|
||||
|
||||
let _ = ml.export_file("test_blocks.txt", "test_mutes.txt", (200, 150));
|
||||
let _ = ml.export_file("test/test_blocks.txt", "test/test_mutes.txt", (200, 150));
|
||||
|
||||
let blocks: String = fs::read_to_string("test_blocks.txt").unwrap();
|
||||
let mutes: String = fs::read_to_string("test_mutes.txt").unwrap();
|
||||
let file_blocks: String = fs::read_to_string("test/test_blocks.txt").unwrap();
|
||||
let file_mutes: String = fs::read_to_string("test/test_mutes.txt").unwrap();
|
||||
|
||||
assert_eq!(blocks, "example.com\n");
|
||||
assert_eq!(mutes, "example.net\nexample.org\n");
|
||||
assert_eq!(file_blocks, "example.com\n");
|
||||
assert_eq!(file_mutes, "example.net\nexample.org\n");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue