Make all command stuff public

This commit is contained in:
Joscha 2021-11-08 12:13:10 +00:00
parent 09f83930b4
commit 0718883a80

View file

@ -1,7 +1,7 @@
use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
#[derive(Debug)] #[derive(Debug)]
enum Weekday { pub enum Weekday {
Monday, Monday,
Tuesday, Tuesday,
Wednesday, Wednesday,
@ -12,7 +12,7 @@ enum Weekday {
} }
#[derive(Debug)] #[derive(Debug)]
enum DeltaStep { pub enum DeltaStep {
/// `y`, move by a year, keeping the same month and day /// `y`, move by a year, keeping the same month and day
Year(i32), Year(i32),
/// `m`, move by a month, keeping the same day `d` /// `m`, move by a month, keeping the same day `d`
@ -44,37 +44,37 @@ pub struct Delta {
} }
#[derive(Debug)] #[derive(Debug)]
struct DateEndSpec { pub struct DateEndSpec {
end: Option<NaiveDate>, pub end: Option<NaiveDate>,
delta: Option<Delta>, pub delta: Option<Delta>,
end_time: Option<NaiveTime>, pub end_time: Option<NaiveTime>,
} }
#[derive(Debug)] #[derive(Debug)]
struct DateSpec { pub struct DateSpec {
start: NaiveDate, pub start: NaiveDate,
delta: Option<Delta>, pub delta: Option<Delta>,
start_time: Option<NaiveTime>, pub start_time: Option<NaiveTime>,
end: Option<DateEndSpec>, pub end: Option<DateEndSpec>,
repeat: Option<Delta>, pub repeat: Option<Delta>,
} }
#[derive(Debug)] #[derive(Debug)]
struct WeekdayEndSpec { pub struct WeekdayEndSpec {
end: Option<Weekday>, pub end: Option<Weekday>,
delta: Option<Delta>, pub delta: Option<Delta>,
end_time: Option<NaiveTime>, pub end_time: Option<NaiveTime>,
} }
#[derive(Debug)] #[derive(Debug)]
struct WeekdaySpec { pub struct WeekdaySpec {
start: Weekday, pub start: Weekday,
start_time: Option<NaiveTime>, pub start_time: Option<NaiveTime>,
end: Option<WeekdayEndSpec>, pub end: Option<WeekdayEndSpec>,
} }
#[derive(Debug)] #[derive(Debug)]
enum IntVar { pub enum IntVar {
/// `j`, see https://en.wikipedia.org/wiki/Julian_day /// `j`, see https://en.wikipedia.org/wiki/Julian_day
JulianDay, JulianDay,
/// `y` /// `y`
@ -142,7 +142,7 @@ enum IntVar {
} }
#[derive(Debug)] #[derive(Debug)]
enum IntExpr { pub enum IntExpr {
Lit(i64), Lit(i64),
Var(IntVar), Var(IntVar),
Paren(Box<IntVar>), Paren(Box<IntVar>),
@ -156,7 +156,7 @@ enum IntExpr {
} }
#[derive(Debug)] #[derive(Debug)]
enum BoolVar { pub enum BoolVar {
/// `isWeekday`, whether the current day is one of mon-fri /// `isWeekday`, whether the current day is one of mon-fri
IsWeekday, IsWeekday,
/// `isWeekend`, whether the current day is one of sat-sun /// `isWeekend`, whether the current day is one of sat-sun
@ -166,7 +166,7 @@ enum BoolVar {
} }
#[derive(Debug)] #[derive(Debug)]
enum BoolExpr { pub enum BoolExpr {
Lit(bool), Lit(bool),
Var(BoolVar), Var(BoolVar),
Paren(Box<BoolVar>), Paren(Box<BoolVar>),
@ -185,56 +185,56 @@ enum BoolExpr {
} }
#[derive(Debug)] #[derive(Debug)]
struct FormulaSpec { pub struct FormulaSpec {
start: Option<BoolExpr>, // None: * pub start: Option<BoolExpr>, // None: *
start_time: Option<NaiveTime>, pub start_time: Option<NaiveTime>,
offset: Option<Delta>, pub offset: Option<Delta>,
end: Option<Delta>, pub end: Option<Delta>,
} }
#[derive(Debug)] #[derive(Debug)]
enum Spec { pub enum Spec {
Date(DateSpec), Date(DateSpec),
Weekday(WeekdaySpec), Weekday(WeekdaySpec),
Formula(FormulaSpec), Formula(FormulaSpec),
} }
#[derive(Debug)] #[derive(Debug)]
struct Done { pub struct Done {
refering_to: Option<NaiveDate>, pub refering_to: Option<NaiveDate>,
created_at: Option<NaiveDateTime>, pub created_at: Option<NaiveDateTime>,
} }
#[derive(Debug)] #[derive(Debug)]
struct Task { pub struct Task {
title: String, pub title: String,
when: Vec<Spec>, pub when: Vec<Spec>,
done: Vec<Done>, pub done: Vec<Done>,
desc: Option<String>, pub desc: Option<String>,
} }
#[derive(Debug)] #[derive(Debug)]
struct Note { pub struct Note {
title: String, pub title: String,
when: Vec<Spec>, // Not empty pub when: Vec<Spec>, // Should not be empty?
desc: Option<String>, pub desc: Option<String>,
} }
#[derive(Debug)] #[derive(Debug)]
struct BirthdaySpec { pub struct BirthdaySpec {
date: NaiveDate, pub date: NaiveDate,
year_known: bool, // If year is unknown, use NaiveDate of year 0 pub year_known: bool, // If year is unknown, use NaiveDate of year 0
} }
#[derive(Debug)] #[derive(Debug)]
struct Birthday { pub struct Birthday {
title: String, pub title: String,
when: BirthdaySpec, pub when: BirthdaySpec,
desc: Option<String>, pub desc: Option<String>,
} }
#[derive(Debug)] #[derive(Debug)]
enum Command { pub enum Command {
Task(Task), Task(Task),
Note(Note), Note(Note),
Birthday(Birthday), Birthday(Birthday),