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)]
|
#![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 anyhow::{ bail, Error as _Error, Result };
|
||||||
use const_format::formatcp;
|
use const_format::formatcp;
|
||||||
use serde::{ Serialize, Deserialize };
|
use serde::{ Serialize, Deserialize };
|
||||||
@ -237,10 +237,10 @@ impl Retriever {
|
|||||||
bail!("Error during requesting Tilda: {:?}", request)
|
bail!("Error during requesting Tilda: {:?}", request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main () {
|
fn main () {
|
||||||
dotenvy::dotenv().ok();
|
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"));
|
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 {
|
match run {
|
||||||
Ok(fetched) => {
|
Ok(fetched) => {
|
||||||
println!("Successfully fetched {} users in {} ms, writing out to {}…", fetched, benchmark.elapsed().as_millis(), out);
|
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
|
// @TODO write
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user