summaryrefslogtreecommitdiffstats
path: root/src/recite
diff options
context:
space:
mode:
Diffstat (limited to 'src/recite')
-rw-r--r--src/recite/erro.rs15
-rw-r--r--src/recite/ps.rs44
2 files changed, 8 insertions, 51 deletions
diff --git a/src/recite/erro.rs b/src/recite/erro.rs
deleted file mode 100644
index 00f57b3..0000000
--- a/src/recite/erro.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-use thiserror::Error;
-
-#[derive(Error, Debug)]
-pub enum Mishap {
- #[error("broken pipe: {0}")]
- BrokenPipe(String),
- // #[error("exec format error: {0}")]
- // ExecFormat(String),
- #[error("permission denied: {0}")]
- PermissionDenied(String),
- #[error("terminated: {0}")]
- Terminated(String),
- #[error("exec error: {0}")]
- Else(String),
-}
diff --git a/src/recite/ps.rs b/src/recite/ps.rs
index 3557505..30c3d7c 100644
--- a/src/recite/ps.rs
+++ b/src/recite/ps.rs
@@ -5,30 +5,15 @@ macro_rules! task {
let mut child = Command::new($verse.verb())
.args($verse.clause())
.stdin(Stdio::piped())
- .spawn()
- .map_err(|e| match e.kind() {
- io::ErrorKind::PermissionDenied => Mishap::PermissionDenied($verse.verb()),
- _ => Mishap::Else($verse.verb()),
- })?;
+ .spawn()?;
- let stdin = child
- .stdin
- .as_mut()
- .ok_or(Mishap::BrokenPipe($verse.verb()))?;
- stdin
- .write_all(&$out.as_bytes())
- .map_err(|_| Mishap::BrokenPipe($verse.verb()))?;
+ let stdin = child.stdin.as_mut().ok_or(io::ErrorKind::BrokenPipe)?;
+ stdin.write_all(&$out.as_bytes())?;
$out.clear();
child
} else {
- Command::new($verse.verb())
- .args($verse.clause())
- .spawn()
- .map_err(|e| match e.kind() {
- io::ErrorKind::PermissionDenied => Mishap::PermissionDenied($verse.verb()),
- _ => Mishap::Else($verse.verb()),
- })?
+ Command::new($verse.verb()).args($verse.clause()).spawn()?
}
};
}
@@ -41,19 +26,10 @@ macro_rules! ctask {
.args($verse.clause())
.stdin(Stdio::piped())
.stdout(Stdio::piped())
- .spawn()
- .map_err(|e| match e.kind() {
- io::ErrorKind::PermissionDenied => Mishap::PermissionDenied($verse.verb()),
- _ => Mishap::Else($verse.verb()),
- })?;
+ .spawn()?;
- let stdin = child
- .stdin
- .as_mut()
- .ok_or(Mishap::BrokenPipe($verse.verb()))?;
- stdin
- .write_all(&$out.as_bytes())
- .map_err(|_| Mishap::BrokenPipe($verse.verb()))?;
+ let stdin = child.stdin.as_mut().ok_or(io::ErrorKind::BrokenPipe)?;
+ stdin.write_all(&$out.as_bytes())?;
$out.clear();
child
@@ -61,11 +37,7 @@ macro_rules! ctask {
Command::new($verse.verb())
.args($verse.clause())
.stdout(Stdio::piped())
- .spawn()
- .map_err(|e| match e.kind() {
- io::ErrorKind::PermissionDenied => Mishap::PermissionDenied($verse.verb()),
- _ => Mishap::Else($verse.verb()),
- })?
+ .spawn()?
}
};
}