more args: mode, style, decis (#20)
This commit is contained in:
60
src/args.rs
60
src/args.rs
@@ -1,10 +1,43 @@
|
||||
use clap::Parser;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use color_eyre::{
|
||||
eyre::{ensure, eyre},
|
||||
Report,
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
|
||||
pub enum Content {
|
||||
#[value(name = "countdown", alias = "c")]
|
||||
Countdown,
|
||||
#[value(name = "timer", alias = "t")]
|
||||
Timer,
|
||||
#[value(name = "pomodoro", alias = "p")]
|
||||
Pomodoro,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, ValueEnum)]
|
||||
pub enum ClockStyle {
|
||||
#[value(name = "bold", alias = "b")]
|
||||
Bold,
|
||||
#[value(name = "empty", alias = "e")]
|
||||
Empty,
|
||||
#[value(name = "thick", alias = "t")]
|
||||
Thick,
|
||||
#[value(name = "cross", alias = "c")]
|
||||
Cross,
|
||||
}
|
||||
|
||||
impl ClockStyle {
|
||||
pub fn next(&self) -> Self {
|
||||
match self {
|
||||
ClockStyle::Bold => ClockStyle::Empty,
|
||||
ClockStyle::Empty => ClockStyle::Thick,
|
||||
ClockStyle::Thick => ClockStyle::Cross,
|
||||
ClockStyle::Cross => ClockStyle::Bold,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Args {
|
||||
#[arg(long, short, value_parser = parse_duration,
|
||||
@@ -22,6 +55,31 @@ pub struct Args {
|
||||
help = "Pause time to count down from. Format: 'ss', 'mm:ss', or 'hh:mm:ss'"
|
||||
)]
|
||||
pub pause: Duration,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
short = 'd',
|
||||
default_value = "false",
|
||||
help = "Wether to show deciseconds or not"
|
||||
)]
|
||||
pub decis: bool,
|
||||
|
||||
#[arg(
|
||||
short = 'm',
|
||||
value_enum,
|
||||
default_value = "timer",
|
||||
help = "Mode to start with: [t]imer, [c]ountdown, [p]omodoro"
|
||||
)]
|
||||
pub mode: Content,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
short = 's',
|
||||
value_enum,
|
||||
default_value = "bold",
|
||||
help = "Style to display time with: [b]old, [t]hick, [c]ross, [e]mpty"
|
||||
)]
|
||||
pub style: ClockStyle,
|
||||
}
|
||||
|
||||
fn parse_duration(arg: &str) -> Result<Duration, Report> {
|
||||
|
||||
Reference in New Issue
Block a user