routine tui
runner nix smoke / nix label and flake smoke (push) Canceled after 0s

This commit is contained in:
2026-10-14 22:59:55 +00:00
parent ba213e1a3b
commit 7bceeb255e
10 changed files with 1900 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize)]
pub struct Task {
pub id: i64,
pub routine_id: Option<i64>,
pub title: String,
pub notes: Option<String>,
pub section: String,
pub priority: String,
pub reminder_time: Option<String>,
pub status: String,
pub completed_at: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Routine {
pub title: String,
pub notes: Option<String>,
pub section: String,
pub priority: String,
pub schedule: Schedule,
pub reminder_time: Option<String>,
pub enabled: bool,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum Schedule {
Daily,
Weekly {
weekdays: Vec<u32>,
},
Monthly {
days: Vec<u32>,
clamp_to_last_day: bool,
},
}
#[derive(Debug, Serialize)]
pub struct CreateTask {
pub title: String,
pub notes: Option<String>,
pub section: String,
pub priority: String,
pub scheduled_date: String,
pub reminder_time: Option<String>,
}
#[derive(Debug, Serialize)]
pub struct CreateRoutine {
pub title: String,
pub notes: Option<String>,
pub section: String,
pub priority: String,
pub schedule: Schedule,
pub reminder_time: Option<String>,
}
#[derive(Debug, Serialize)]
pub struct RescheduleTask {
pub scheduled_date: String,
}
pub fn schedule_label(schedule: &Schedule) -> String {
match schedule {
Schedule::Daily => "daily".to_owned(),
Schedule::Weekly { weekdays } => format!("weekly [{}]", join_numbers(weekdays)),
Schedule::Monthly {
days,
clamp_to_last_day,
} => {
let suffix = if *clamp_to_last_day { ", clamp" } else { "" };
format!("monthly [{}{suffix}]", join_numbers(days))
}
}
}
fn join_numbers(numbers: &[u32]) -> String {
numbers
.iter()
.map(u32::to_string)
.collect::<Vec<_>>()
.join(",")
}