diff options
author | metamuffin <yvchraiqi@protonmail.com> | 2022-06-11 14:32:45 +0200 |
---|---|---|
committer | metamuffin <yvchraiqi@protonmail.com> | 2022-06-11 14:32:45 +0200 |
commit | c2699d114c921ab2ceb1f467b32a26257dddcf3d (patch) | |
tree | 0e886d333d944094c8c66905cac36a21cd010405 /karlc/src/main.rs | |
parent | 9769c17c0b4c271c1cfbe726b19a6d3f9250c7c8 (diff) | |
download | karlender-c2699d114c921ab2ceb1f467b32a26257dddcf3d.tar karlender-c2699d114c921ab2ceb1f467b32a26257dddcf3d.tar.bz2 karlender-c2699d114c921ab2ceb1f467b32a26257dddcf3d.tar.zst |
changing the protocol again
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, } } } |