refactor: make code more readable and maintainable
This commit is contained in:
parent
bd91ea9d90
commit
e3fd65e98b
6 changed files with 135 additions and 137 deletions
12
src/cli.rs
12
src/cli.rs
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue