Skip to content

Commit

Permalink
use std::io::Error::other
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Oct 29, 2024
1 parent e060b3e commit f99cfa8
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/kamp/kak.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use std::io::{Error, ErrorKind, Result, Write};
use std::io::{Error, Result, Write};
use std::process::{Command, ExitStatus, Stdio};

pub(crate) fn list_sessions() -> Result<Vec<u8>> {
let output = Command::new("kak").arg("-l").output()?;

if !output.status.success() {
return Err(match output.status.code() {
Some(code) => Error::new(
ErrorKind::Other,
format!("kak exited with status code: {code}"),
),
None => Error::new(ErrorKind::Other, "kak terminated by signal"),
Some(code) => Error::other(format!("kak exited with status code: {code}")),
None => Error::other("kak terminated by signal"),
});
}

Expand All @@ -29,10 +26,7 @@ where
.spawn()?;

let Some(stdin) = child.stdin.as_mut() else {
return Err(Error::new(
ErrorKind::Other,
"cannot capture stdin of kak process",
));
return Err(Error::other("cannot capture stdin of kak process"));
};

stdin.write_all(cmd.as_ref()).and_then(|_| child.wait())
Expand Down

0 comments on commit f99cfa8

Please sign in to comment.