From 1a36ba5c1d3782c20db0fe99acd31a80763c89bd Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Tue, 26 Jul 2022 22:03:52 +0200 Subject: [PATCH] refresh_json: add option to skip weekly events --- src/bin/refresh_json.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bin/refresh_json.rs b/src/bin/refresh_json.rs index fcc7f50..1409095 100644 --- a/src/bin/refresh_json.rs +++ b/src/bin/refresh_json.rs @@ -1,8 +1,9 @@ -use std::{error::Error, fs}; +use std::{env, error::Error, fs}; static WEEKLY: &'static str = include_str!("../../events_weekly.json"); fn main() { + let args = env::args().skip(1).collect::>(); let url = "http://nixos.fritz.box:12783/custom/event_alerts"; if let Ok(json) = get_json(url) { @@ -11,7 +12,11 @@ fn main() { buf += "\"events\": "; buf += &json; buf += ","; - buf += WEEKLY; + if args.len() >= 1 && args[0] == "--no-weekly" { + buf += r#""weekly": []"#; + } else { + buf += WEEKLY; + } buf += "}"; fs::write("events.json", buf.as_bytes()).unwrap(); } @@ -19,4 +24,4 @@ fn main() { fn get_json(url: &str) -> Result> { Ok(ureq::get(url).call()?.into_string()?) -} \ No newline at end of file +}