NYI macro, cleanup transition function
This commit is contained in:
parent
60956b6303
commit
92d87193a8
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
stdext = "0.3.3"
|
||||||
pandoc = "0.8"
|
pandoc = "0.8"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
regex = "1.10.5"
|
regex = "1.10.5"
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
|
|
||||||
use crate::is_dry_run;
|
use crate::is_dry_run;
|
||||||
use crate::key_value::KeyValueStore as KV;
|
use crate::key_value::KeyValueStore as KV;
|
||||||
|
use crate::NYI;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ impl<'a> CfgField<'a> {
|
||||||
/// Ensure all fields with known default values exist.
|
/// Ensure all fields with known default values exist.
|
||||||
pub fn populate_defaults(spec: &CfgSpec, config: &KV) {
|
pub fn populate_defaults(spec: &CfgSpec, config: &KV) {
|
||||||
for group in spec.groups {
|
for group in spec.groups {
|
||||||
|
NYI!("asdf");
|
||||||
for field in group.fields {
|
for field in group.fields {
|
||||||
match field {
|
match field {
|
||||||
CfgField::Silent { default, .. } => {
|
CfgField::Silent { default, .. } => {
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -16,3 +16,21 @@ use std::env;
|
||||||
pub fn is_dry_run() -> bool {
|
pub fn is_dry_run() -> bool {
|
||||||
env::var("DRY_RUN").map(|v| !v.is_empty()).unwrap_or(false)
|
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);
|
||||||
|
});
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -52,6 +52,7 @@ use cccron_lib::email::{self, Email, SimpleEmail};
|
||||||
use cccron_lib::hedgedoc::{self, HedgeDoc};
|
use cccron_lib::hedgedoc::{self, HedgeDoc};
|
||||||
use cccron_lib::is_dry_run;
|
use cccron_lib::is_dry_run;
|
||||||
use cccron_lib::mediawiki::{self, Mediawiki};
|
use cccron_lib::mediawiki::{self, Mediawiki};
|
||||||
|
use cccron_lib::NYI;
|
||||||
|
|
||||||
const FALLBACK_TEMPLATE: &str = variables_and_settings::FALLBACK_TEMPLATE;
|
const FALLBACK_TEMPLATE: &str = variables_and_settings::FALLBACK_TEMPLATE;
|
||||||
|
|
||||||
|
@ -737,14 +738,20 @@ fn do_reminder(
|
||||||
hedgedoc.format_url(¤t_pad_id)
|
hedgedoc.format_url(¤t_pad_id)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
"Da es immer noch keine Themen gibt fällt das Plenum aus.\n\n".to_string()
|
NYI!("generate link / pad for next plenum & include in this email");
|
||||||
+ "(Natürlich könnt ihr im Bedarfsfall immer noch kurzfristig ein Treffen einberufen, aber bitte "
|
"Da es immer noch keine Themen gibt fällt das Plenum aus.\n\n\
|
||||||
+ "kündigt das so früh wie möglich an, damit Leute sich darauf einstellen können.)"
|
(Natürlich könnt ihr im Bedarfsfall immer noch kurzfristig ein Treffen einberufen, aber bitte \
|
||||||
// TODO generate + add link for next pad
|
kündigt das so früh wie möglich an, damit Leute sich darauf einstellen können.)"
|
||||||
|
.to_string()
|
||||||
};
|
};
|
||||||
// send it
|
// send it
|
||||||
let _message_id = send_email(&subject, &body, &email, &config)?;
|
let _message_id = send_email(&subject, &body, &email, &config)?;
|
||||||
// on success, update state (ignore write errors, they'll be checked later)
|
// 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-name", &ProgramState::Reminded.to_string()).ok();
|
||||||
config.set("state-toc", &toc).ok();
|
config.set("state-toc", &toc).ok();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -764,14 +771,17 @@ fn do_protocol(
|
||||||
|
|
||||||
/// General cleanup function. Call as `(999, today, …)` for a complete reset
|
/// General cleanup function. Call as `(999, today, …)` for a complete reset
|
||||||
/// based on today as the base date.
|
/// based on today as the base date.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_must_use)]
|
||||||
fn do_cleanup(
|
fn do_cleanup(
|
||||||
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
_ttp: i64, _plenum_day: &NaiveDate, config: &KV, _hedgedoc: &HedgeDoc, _email: &SimpleEmail,
|
||||||
wiki: &Mediawiki,
|
_wiki: &Mediawiki,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
// TODO: reset any state vars (e.g. summary)
|
config.delete("state-toc");
|
||||||
// TODO: set state back to normal
|
config.delete("email-last-message-id");
|
||||||
todo!()
|
NYI!("rotate pad links");
|
||||||
|
NYI!("double-check state for leftovers");
|
||||||
|
config.set("state-name", &ProgramState::Normal.to_string());
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***** state machine ***** */
|
/* ***** state machine ***** */
|
||||||
|
|
Loading…
Reference in a new issue