Represent commands in file uniformly

This commit is contained in:
Joscha 2022-01-02 00:42:06 +01:00
parent 004aa87153
commit d27812b836
3 changed files with 25 additions and 73 deletions

View file

@ -345,38 +345,15 @@ pub struct Log {
#[derive(Debug)]
pub enum Command {
Include(String),
Timezone(String),
Task(Task),
Note(Note),
}
impl Command {
pub fn title(&self) -> &str {
match self {
Self::Task(task) => &task.title,
Self::Note(note) => &note.title,
}
}
pub fn desc(&self) -> &[String] {
match self {
Self::Task(task) => &task.desc,
Self::Note(note) => &note.desc,
}
}
pub fn statements(&self) -> &[Statement] {
match self {
Self::Task(task) => &task.statements,
Self::Note(note) => &note.statements,
}
}
Log(Log),
}
#[derive(Debug)]
pub struct File {
pub contents: String,
pub includes: Vec<String>,
pub timezone: Option<String>,
pub logs: Vec<Log>,
pub commands: Vec<Command>,
}