feat: add notifications

This commit is contained in:
Moritz Böhme 2023-07-29 10:41:56 +02:00
parent b3885f80dd
commit dfd0b52d50
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
5 changed files with 1129 additions and 20 deletions

View file

@ -1,4 +1,4 @@
use crate::daemon::{Answer, Command as OtherCommand, AnswerErr};
use crate::daemon::{Answer, AnswerErr, Command as OtherCommand};
use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
use std::net::Shutdown;
@ -18,10 +18,18 @@ pub struct Cli {
#[derive(Debug, Subcommand)]
pub enum Command {
Daemon,
Add { name: String, duration_seconds: u64 },
Daemon {
#[arg(short, long)]
notify: bool,
},
Add {
name: String,
duration_seconds: u64,
},
List,
Remove { name: String },
Remove {
name: String,
},
}
fn get_stream(socket_path: &String) -> Result<UnixStream> {
@ -35,7 +43,8 @@ pub fn send_command(socket_path: &String, command: OtherCommand) -> Result<()> {
stream
.shutdown(Shutdown::Write)
.context("Could not shutdown write!")?;
let answer: Result<Answer, AnswerErr> = serde_cbor::from_reader(&stream).context("Could not read answer!")?;
let answer: Result<Answer, AnswerErr> =
serde_cbor::from_reader(&stream).context("Could not read answer!")?;
match answer {
Ok(answer) => println!("{}", answer),
Err(err) => println!("Error: {}", err),