Compare commits

...

2 Commits

Author SHA1 Message Date
FliegendeWurst
5cac88580d fix cross compile 2022-07-26 22:04:40 +02:00
FliegendeWurst
1a36ba5c1d refresh_json: add option to skip weekly events 2022-07-26 22:03:52 +02:00
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
with (import <nixpkgs> {}); with (import <nixpkgs> {});
mkShell { mkShell {
nativeBuildInputs = [ buildInputs = [
pkgsCross.muslpi.stdenv.cc pkgsCross.muslpi.stdenv.cc
pkgsCross.muslpi.sqlite pkgsCross.muslpi.sqlite
]; ];

View File

@ -1,8 +1,9 @@
use std::{error::Error, fs}; use std::{env, error::Error, fs};
static WEEKLY: &'static str = include_str!("../../events_weekly.json"); static WEEKLY: &'static str = include_str!("../../events_weekly.json");
fn main() { fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
let url = "http://nixos.fritz.box:12783/custom/event_alerts"; let url = "http://nixos.fritz.box:12783/custom/event_alerts";
if let Ok(json) = get_json(url) { if let Ok(json) = get_json(url) {
@ -11,7 +12,11 @@ fn main() {
buf += "\"events\": "; buf += "\"events\": ";
buf += &json; buf += &json;
buf += ","; buf += ",";
buf += WEEKLY; if args.len() >= 1 && args[0] == "--no-weekly" {
buf += r#""weekly": []"#;
} else {
buf += WEEKLY;
}
buf += "}"; buf += "}";
fs::write("events.json", buf.as_bytes()).unwrap(); fs::write("events.json", buf.as_bytes()).unwrap();
} }