From a6581455e76aea341ddd082fc32b90c330c82c13 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 18 Apr 2024 22:01:39 +0200 Subject: [PATCH] Add support for file word-lists --- src/main.rs | 17 ++++++++++++++++- test-list.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test-list.txt diff --git a/src/main.rs b/src/main.rs index 3fc28c4..879e63c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,10 @@ use crate::rentry::{build_client, edit_paste, CSRFData, EditError}; +use std::{ + fs::File, + io::{BufRead, BufReader}, +}; + mod rentry; const PASTE_NAME: &str = "Hyprland-controversy"; @@ -35,6 +40,15 @@ where } } +impl EditCodeGenerator> { + pub fn from_file(file_path: &str) -> Result { + let file = File::open(file_path)?; + let reader = BufReader::new(file); + let lines = reader.lines().collect::, _>>()?; + Ok(EditCodeGenerator::new(lines.into_iter())) + } +} + impl Iterator for EditCodeGenerator where I: Iterator, @@ -69,7 +83,8 @@ fn main() { let client = build_client(); let mut csrf_data = CSRFData::get(&client, PASTE_NAME); - let mut edit_codes = EditCodeGenerator::default(); + let mut edit_codes = EditCodeGenerator::from_file("test-list.txt").unwrap(); + //let mut edit_codes = EditCodeGenerator::default(); while let Some(edit_code) = edit_codes.next() { match edit_paste(&client, &csrf_data, &edit_code, PASTE_NAME) { diff --git a/test-list.txt b/test-list.txt new file mode 100644 index 0000000..0edb856 --- /dev/null +++ b/test-list.txt @@ -0,0 +1,26 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z