From 672d7d3b36cd66b42a561a91319a87fd9f92f567 Mon Sep 17 00:00:00 2001 From: YK Date: Wed, 16 Apr 2025 09:08:30 +0300 Subject: [PATCH] feat: write fetched data to a file --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index d48b343..15052a0 100644 --- a/src/main.rs +++ b/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) => {