feat: write fetched data to a file
This commit is contained in:
parent
9d6502ee30
commit
672d7d3b36
10
src/main.rs
10
src/main.rs
@ -1,6 +1,6 @@
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use std::{ env, fs::File, io::Read, thread::sleep, time::{ Duration, Instant } };
|
||||
use std::{ env, fs::{ self, File }, io::Read, thread::sleep, time::{ Duration, Instant } };
|
||||
use anyhow::{ bail, Error as _Error, Result };
|
||||
use const_format::formatcp;
|
||||
use serde::{ Serialize, Deserialize };
|
||||
@ -237,10 +237,10 @@ impl Retriever {
|
||||
bail!("Error during requesting Tilda: {:?}", request)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main () {
|
||||
dotenvy::dotenv().ok();
|
||||
let cookie = read_cookie(cookie_filename).expect(&format!("Directory with executable should contain `{cookie_filename}` file containing a valid cookie for accessing Tilda control panel"));
|
||||
@ -254,6 +254,12 @@ fn main () {
|
||||
match run {
|
||||
Ok(fetched) => {
|
||||
println!("Successfully fetched {} users in {} ms, writing out to {}…", fetched, benchmark.elapsed().as_millis(), out);
|
||||
|
||||
let s = serde_json::to_string_pretty(&retriever.out).unwrap();
|
||||
|
||||
let write = fs::write(out, s);
|
||||
|
||||
println!("{:?}", write);
|
||||
// @TODO write
|
||||
},
|
||||
Err(e) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user