Compare commits

..

No commits in common. "739f76fa90271860e2c1d683e3a53cfb93e6eb89" and "323c2fba18bc0d46f9582b53b99d87f68afddc2d" have entirely different histories.

6 changed files with 9 additions and 58 deletions

32
Cargo.lock generated
View File

@ -651,12 +651,6 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "itoa"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.147" version = "0.2.147"
@ -981,17 +975,11 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "ryu"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.179" version = "1.0.164"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0" checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -1008,26 +996,15 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.179" version = "1.0.164"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.27", "syn 2.0.27",
] ]
[[package]]
name = "serde_json"
version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]] [[package]]
name = "serde_repr" name = "serde_repr"
version = "0.1.16" version = "0.1.16"
@ -1193,7 +1170,6 @@ dependencies = [
"notify-rust", "notify-rust",
"serde", "serde",
"serde_cbor", "serde_cbor",
"serde_json",
"signal-hook", "signal-hook",
"thiserror", "thiserror",
] ]

View File

@ -14,6 +14,5 @@ libc = "0.2.147"
notify-rust = "4.8.0" notify-rust = "4.8.0"
serde = { version = "1.0.164", features = ["derive"] } serde = { version = "1.0.164", features = ["derive"] }
serde_cbor = "0.11.2" serde_cbor = "0.11.2"
serde_json = "1.0.105"
signal-hook = "0.3.17" signal-hook = "0.3.17"
thiserror = "1.0.44" thiserror = "1.0.44"

View File

@ -12,13 +12,9 @@ use std::time::Duration;
pub struct Cli { pub struct Cli {
#[command(subcommand)] #[command(subcommand)]
pub command: Command, pub command: Command,
#[arg(short, long)] #[arg(short, long)]
#[clap(default_value_t = format!("{}/timers.socket", run_path()))] #[clap(default_value_t = format!("{}/timers.socket", run_path()))]
pub socket: String, pub socket: String,
#[arg(long)]
pub json: bool
} }
#[derive(Debug, Subcommand)] #[derive(Debug, Subcommand)]

View File

@ -48,10 +48,6 @@ fn main() -> Result<(), anyhow::Error> {
} }
}; };
let answer = send_command(&args.socket, daemon_command)?; let answer = send_command(&args.socket, daemon_command)?;
if args.json {
println!("{}", serde_json::to_string(&answer)?)
} else {
print!("{}", answer); print!("{}", answer);
};
Ok(()) Ok(())
} }

View File

@ -19,11 +19,10 @@ impl Display for Pomodoro {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!( write!(
f, f,
"Pomodoro ({}, {}, {}) currently {} {} with {} remaining.\n", "Pomodoro ({}, {}, {}) currently {} with {} remaining.\n",
humantime::format_duration(self.work), humantime::format_duration(self.work),
humantime::format_duration(self.pause), humantime::format_duration(self.pause),
humantime::format_duration(self.long_pause), humantime::format_duration(self.long_pause),
self.timer.state,
self.status, self.status,
humantime::format_duration(self.timer.remaining()) humantime::format_duration(self.timer.remaining())
) )

View File

@ -11,7 +11,7 @@ pub struct Timer {
#[serde(with = "approx_instant")] #[serde(with = "approx_instant")]
start: Instant, start: Instant,
duration: Duration, duration: Duration,
pub state: State, state: State,
} }
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
@ -20,16 +20,6 @@ pub enum State {
Paused, Paused,
} }
impl Display for State {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let string = match self {
State::Running => "running",
State::Paused => "paused",
};
write!(f, "{}", string)
}
}
impl Timer { impl Timer {
/// Create a new [`Timer`] with the supplied name and duration /// Create a new [`Timer`] with the supplied name and duration
/// The timer is instantly started. /// The timer is instantly started.
@ -82,16 +72,10 @@ impl Timer {
impl Display for Timer { impl Display for Timer {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
let state_message = match self.state {
State::Running => "has",
State::Paused => "is paused and has",
};
write!( write!(
f, f,
"'{}' {} {} remaining.", "{} has {} remaining.",
self.name, self.name,
state_message,
humantime::format_duration(self.remaining()) humantime::format_duration(self.remaining())
) )
} }
@ -123,3 +107,4 @@ mod approx_instant {
Ok(instant) Ok(instant)
} }
} }