diff options
Diffstat (limited to 'karlc/src/main.rs')
-rw-r--r-- | karlc/src/main.rs | 82 |
1 files changed, 46 insertions, 36 deletions
diff --git a/karlc/src/main.rs b/karlc/src/main.rs index e95b5b7..55bb974 100644 --- a/karlc/src/main.rs +++ b/karlc/src/main.rs @@ -4,7 +4,9 @@ pub mod pretty; use chrono::{NaiveDateTime, Utc}; use clap::{Args, Parser, Subcommand}; use client::Client; -use karlcommon::{socket_path, version, ClientboundPacket, ServerboundPacket, Task}; +use karlcommon::{ + socket_path, version, ClientboundPacket, Condition, Schedule, ServerboundPacket, Task, +}; use log::{error, info}; use std::{os::unix::net::UnixStream, path::PathBuf, process::exit}; @@ -91,37 +93,49 @@ fn main() { t.description .unwrap_or("\x1b[3m\x1b[2m(no description)\x1b[0m".to_string()) ); - if let Some(o) = t.occurence { - println!( - " \x1b[38;2;100;255;100mOccurence:\x1b[0m {}", - fmt_condition(&o) - ); - print!(" \x1b[38;2;100;255;100mNext instances: \x1b[0m"); + if !t.tags.is_empty() { + println!(" \x1b[38;2;100;255;100mTags:\x1b[0m {}", t.tags.join(", ")); + } + print!(" \x1b[38;2;100;255;100mSchedule: \x1b[0m",); + match t.schedule { + Schedule::Never => println!("\x1b[3m\x1b[2m(never)\x1b[0m"), + Schedule::Dynamic { .. } => todo!(), + Schedule::Static(t) => { + println!( + "from {} to {}", + NaiveDateTime::from_timestamp(t.start, 0), + NaiveDateTime::from_timestamp(t.end, 0) + ) + } + Schedule::Condition(o) => { + println!("when {}", fmt_condition(&o)); + print!(" \x1b[38;2;100;255;100mNext instances: \x1b[0m"); - client.send(ServerboundPacket::ListInstances { - task: t.id, - limit: 5, - range: Some(Utc::now().naive_local().timestamp())..None, - }); - if let ClientboundPacket::InstanceList(instances) = - client.receiver.recv().unwrap() - { - for i in instances { - println!( - "\x1b[19G{} - {}", - i.at.start - .map(|e| format!( - "{}", - NaiveDateTime::from_timestamp(e as i64, 0) - )) - .unwrap_or("...".to_string()), - i.at.end - .map(|e| format!( - "{}", - NaiveDateTime::from_timestamp(e as i64, 0) - )) - .unwrap_or("...".to_string()), - ); + client.send(ServerboundPacket::ListInstances { + task: t.id, + limit: 5, + range: Some(Utc::now().naive_local().timestamp())..None, + }); + if let ClientboundPacket::InstanceList(instances) = + client.receiver.recv().unwrap() + { + for i in instances { + println!( + "\x1b[19G{} - {}", + i.at.start + .map(|e| format!( + "{}", + NaiveDateTime::from_timestamp(e, 0) + )) + .unwrap_or("...".to_string()), + i.at.end + .map(|e| format!( + "{}", + NaiveDateTime::from_timestamp(e, 0) + )) + .unwrap_or("...".to_string()), + ); + } } } } @@ -156,11 +170,7 @@ impl TaskSpec { name: self.name, description: self.description, tags: self.tags, - priority: 0.0, - completed: None, - scheduled: None, - occurence: None, - deadline: None, + schedule: Schedule::Never, } } } |