From 92d87193a8feeea89a53866379bca2f9e6c868f4 Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 23 Aug 2024 22:08:32 +0200 Subject: [PATCH] NYI macro, cleanup transition function --- Cargo.toml | 1 + src/config_spec.rs | 2 ++ src/lib.rs | 18 ++++++++++++++++++ src/main.rs | 30 ++++++++++++++++++++---------- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cfad095..73cc0f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +stdext = "0.3.3" pandoc = "0.8" chrono = "0.4.38" regex = "1.10.5" diff --git a/src/config_spec.rs b/src/config_spec.rs index a4d838f..1cfc817 100644 --- a/src/config_spec.rs +++ b/src/config_spec.rs @@ -57,6 +57,7 @@ use crate::is_dry_run; use crate::key_value::KeyValueStore as KV; +use crate::NYI; use std::error::Error; use std::io::{self, Write}; @@ -217,6 +218,7 @@ impl<'a> CfgField<'a> { /// Ensure all fields with known default values exist. pub fn populate_defaults(spec: &CfgSpec, config: &KV) { for group in spec.groups { + NYI!("asdf"); for field in group.fields { match field { CfgField::Silent { default, .. } => { diff --git a/src/lib.rs b/src/lib.rs index 4b27f86..2ca3bcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,3 +16,21 @@ use std::env; pub fn is_dry_run() -> bool { env::var("DRY_RUN").map(|v| !v.is_empty()).unwrap_or(false) } + +#[macro_export] +macro_rules! NYI { + ($msg:expr) => {{ + static ONCE: std::sync::Once = std::sync::Once::new(); + let location = stdext::debug_name!(); + ONCE.call_once(|| { + eprintln!("{}: NYI -- {}", location, $msg); + }); + }}; + () => {{ + static ONCE: std::sync::Once = std::sync::Once::new(); + let location = stdext::debug_name!(); + ONCE.call_once(|| { + eprintln!("{}: NYI!", location); + }); + }}; +} diff --git a/src/main.rs b/src/main.rs index ce1c9a4..efe6b47 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,7 @@ use cccron_lib::email::{self, Email, SimpleEmail}; use cccron_lib::hedgedoc::{self, HedgeDoc}; use cccron_lib::is_dry_run; use cccron_lib::mediawiki::{self, Mediawiki}; +use cccron_lib::NYI; const FALLBACK_TEMPLATE: &str = variables_and_settings::FALLBACK_TEMPLATE; @@ -737,14 +738,20 @@ fn do_reminder( hedgedoc.format_url(¤t_pad_id) ) } else { - "Da es immer noch keine Themen gibt fällt das Plenum aus.\n\n".to_string() - + "(Natürlich könnt ihr im Bedarfsfall immer noch kurzfristig ein Treffen einberufen, aber bitte " - + "kündigt das so früh wie möglich an, damit Leute sich darauf einstellen können.)" - // TODO generate + add link for next pad + NYI!("generate link / pad for next plenum & include in this email"); + "Da es immer noch keine Themen gibt fällt das Plenum aus.\n\n\ + (Natürlich könnt ihr im Bedarfsfall immer noch kurzfristig ein Treffen einberufen, aber bitte \ + kündigt das so früh wie möglich an, damit Leute sich darauf einstellen können.)" + .to_string() }; // send it let _message_id = send_email(&subject, &body, &email, &config)?; // on success, update state (ignore write errors, they'll be checked later) + if n_topics == 0 { + NYI!( + "do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?" + ); + } config.set("state-name", &ProgramState::Reminded.to_string()).ok(); config.set("state-toc", &toc).ok(); Ok(()) @@ -764,14 +771,17 @@ fn do_protocol( /// General cleanup function. Call as `(999, today, …)` for a complete reset /// based on today as the base date. -#[allow(unused_variables)] +#[allow(unused_must_use)] fn do_cleanup( - ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail, - wiki: &Mediawiki, + _ttp: i64, _plenum_day: &NaiveDate, config: &KV, _hedgedoc: &HedgeDoc, _email: &SimpleEmail, + _wiki: &Mediawiki, ) -> Result<(), Box> { - // TODO: reset any state vars (e.g. summary) - // TODO: set state back to normal - todo!() + config.delete("state-toc"); + config.delete("email-last-message-id"); + NYI!("rotate pad links"); + NYI!("double-check state for leftovers"); + config.set("state-name", &ProgramState::Normal.to_string()); + Ok(()) } /* ***** state machine ***** */