diff --git a/Cargo.lock b/Cargo.lock index 31b72ff..fb01205 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,16 @@ dependencies = [ "clap", "env_logger", "log", + "url", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", ] [[package]] @@ -150,6 +160,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -168,6 +188,12 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "proc-macro2" version = "1.0.84" @@ -232,12 +258,53 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index bc37b1d..30f4de7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ description = "Combines blocklists for ActivityPub software" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.11.3" log = "0.4.21" +url = "2.5.0" diff --git a/blocks.txt b/blocks.txt deleted file mode 100644 index de54ac6..0000000 --- a/blocks.txt +++ /dev/null @@ -1 +0,0 @@ -example.com diff --git a/mutes.txt b/mutes.txt deleted file mode 100644 index db90029..0000000 --- a/mutes.txt +++ /dev/null @@ -1,2 +0,0 @@ -example.net -example.org diff --git a/src/main.rs b/src/main.rs index fce425d..b81a7ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,30 +6,42 @@ mod tests; use std::path::PathBuf; use clap::Parser; +use log::error; #[derive(Parser)] #[command(version, about, long_about = None)] struct Cli { - /// Selects a custom config file (optional) + /// Selects a custom config file config: Option, - /// Sets output directory (optional, defaults to current directory) - output_dir: Option, - - /// Specifies block files/directories - #[arg(short, long)] + /// Specifies files/directories for blocks + #[arg(short = 'B', long)] block: Vec, - /// Specifies silence files/directories - #[arg(short, long)] + /// Specifies files/directories for silences + #[arg(short = 'M', long)] mute: Vec, + + /// Specifies confidence in a source. Default = 100 + #[arg(short, long)] + trust: Vec, + + /// Sets output directory (optional, defaults to current directory) + #[arg(last = true)] + path: Option, // TODO more options // TODO verbose mode } fn main() { + env_logger::init(); + let cli = Cli::parse(); + if cli.block.is_empty() && cli.mute.is_empty() && cli.config.is_none() { + error!("No lists or configuration provided."); + } + // TODO argument parsing - IN PROGRESS // TODO logging } diff --git a/src/manip.rs b/src/manip.rs index 62472af..9a38e76 100644 --- a/src/manip.rs +++ b/src/manip.rs @@ -31,6 +31,8 @@ impl ModActionTrust { } impl From<(u16, u16)> for ModActionTrust { + /// Creates mod action weights from a tuple of two `u16` weights. Useful + /// mostly for testing. fn from(value: (u16, u16)) -> Self { Self { block: value.0,