refactor: make code more readable and maintainable

This commit is contained in:
Moritz Böhme 2023-07-30 22:46:09 +02:00
parent bd91ea9d90
commit e3fd65e98b
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
6 changed files with 135 additions and 137 deletions

View file

@ -44,7 +44,7 @@ pub enum Command {
#[clap(visible_alias = "t")]
Toggle {
/// name of the timer to toggle
name: String
name: String,
},
/// Remove a timer
#[clap(visible_alias = "r")]
@ -91,16 +91,12 @@ pub enum PomodoroCommand {
List,
/// Toggle pomodoro
#[clap(visible_alias = "t")]
Toggle
}
fn get_stream(socket_path: &String) -> Result<UnixStream> {
UnixStream::connect(socket_path)
.context(format!("Could not connect to socket {}!", socket_path))
Toggle,
}
pub fn send_command(socket_path: &String, command: OtherCommand) -> Result<Answer> {
let stream = get_stream(socket_path)?;
let stream = UnixStream::connect(socket_path)
.context(format!("Could not connect to socket {}!", socket_path))?;
serde_cbor::to_writer(&stream, &command).context("Could not write command!")?;
stream
.shutdown(Shutdown::Write)