feat: add notifications
This commit is contained in:
parent
b3885f80dd
commit
dfd0b52d50
5 changed files with 1129 additions and 20 deletions
19
src/cli.rs
19
src/cli.rs
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue