feat: better durations and allow stopping pomodoro

This commit is contained in:
Moritz Böhme 2023-07-29 12:52:50 +02:00
parent 103c6d779e
commit 0c954962cc
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
7 changed files with 81 additions and 49 deletions

View file

@ -3,6 +3,7 @@ use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
use std::net::Shutdown;
use std::os::unix::net::UnixStream;
use std::time::Duration;
#[derive(Debug, Parser)]
#[command(name = "timers")]
@ -24,22 +25,29 @@ pub enum Command {
},
Add {
name: String,
duration_seconds: u64,
duration: humantime::Duration,
},
List,
Remove {
name: String,
},
Pomodoro {
#[clap(default_value_t = 25)]
work_minutes: u64,
#[clap(default_value_t = 5)]
pause_minutes: u64,
#[clap(default_value_t = 10)]
long_pause_minutes: u64,
#[command(subcommand)]
Pomodoro(PomodoroCommand)
}
#[derive(Debug, Subcommand)]
pub enum PomodoroCommand {
Start {
#[clap(default_value_t = Duration::from_secs(25 * 60).into())]
work: humantime::Duration,
#[clap(default_value_t = Duration::from_secs(5 * 60).into())]
pause: humantime::Duration,
#[clap(default_value_t = Duration::from_secs(10 * 60).into())]
long_pause: humantime::Duration,
#[clap(default_value_t = 3)]
pauses_till_long: u64,
}
},
Stop,
}
fn get_stream(socket_path: &String) -> Result<UnixStream> {