Skip to content

Commit

Permalink
Print json to stdout instead of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
morr0ne committed Nov 23, 2024
1 parent 08ffd2f commit 65f5821
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions gen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use anyhow::Result;
use clap::Parser;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use std::{collections::HashMap, fmt::Write as _, fs::OpenOptions, io::Write as _};
use std::{
collections::HashMap,
fmt::Write as _,
fs::OpenOptions,
io::{stdout, Write as _},
};
use tracing::info;

use waynest_gen::{
Expand Down Expand Up @@ -40,13 +45,9 @@ fn main() -> Result<()> {
if json {
info!("Generating json file");

let mut json_path = OpenOptions::new()
.truncate(true)
.write(true)
.create(true)
.open("protocols.json")?;
let mut stdout = stdout().lock();

serde_json::to_writer(&mut json_path, &protocols)?;
serde_json::to_writer(&mut stdout, &protocols)?;
} else {
let mut module_content = "pub mod core;".to_string();

Expand Down

0 comments on commit 65f5821

Please sign in to comment.