Add support for file word-lists
This commit is contained in:
parent
567da290dd
commit
a6581455e7
17
src/main.rs
17
src/main.rs
|
@ -1,5 +1,10 @@
|
||||||
use crate::rentry::{build_client, edit_paste, CSRFData, EditError};
|
use crate::rentry::{build_client, edit_paste, CSRFData, EditError};
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::{BufRead, BufReader},
|
||||||
|
};
|
||||||
|
|
||||||
mod rentry;
|
mod rentry;
|
||||||
|
|
||||||
const PASTE_NAME: &str = "Hyprland-controversy";
|
const PASTE_NAME: &str = "Hyprland-controversy";
|
||||||
|
@ -35,6 +40,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EditCodeGenerator<std::vec::IntoIter<String>> {
|
||||||
|
pub fn from_file(file_path: &str) -> Result<Self, std::io::Error> {
|
||||||
|
let file = File::open(file_path)?;
|
||||||
|
let reader = BufReader::new(file);
|
||||||
|
let lines = reader.lines().collect::<Result<Vec<_>, _>>()?;
|
||||||
|
Ok(EditCodeGenerator::new(lines.into_iter()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<I> Iterator for EditCodeGenerator<I>
|
impl<I> Iterator for EditCodeGenerator<I>
|
||||||
where
|
where
|
||||||
I: Iterator<Item = String>,
|
I: Iterator<Item = String>,
|
||||||
|
@ -69,7 +83,8 @@ fn main() {
|
||||||
let client = build_client();
|
let client = build_client();
|
||||||
let mut csrf_data = CSRFData::get(&client, PASTE_NAME);
|
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() {
|
while let Some(edit_code) = edit_codes.next() {
|
||||||
match edit_paste(&client, &csrf_data, &edit_code, PASTE_NAME) {
|
match edit_paste(&client, &csrf_data, &edit_code, PASTE_NAME) {
|
||||||
|
|
26
test-list.txt
Normal file
26
test-list.txt
Normal file
|
@ -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
|
Loading…
Reference in a new issue