summaryrefslogtreecommitdiff
path: root/src/client/executor
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-14 00:29:34 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-14 00:29:34 +0800
commit4f75bc1b3fd85a7b54cf6bbb6e895c2deb353299 (patch)
tree64f4724c1d5e19314e2f6e93448c295279e07896 /src/client/executor
parentaf71458da96fdc7699bed2d04c677a352f5af5fe (diff)
feat(executor): integrate into httpconnector
cleanup: main
Diffstat (limited to 'src/client/executor')
-rw-r--r--src/client/executor/tasks.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/client/executor/tasks.rs b/src/client/executor/tasks.rs
index c69b310..4c8cdee 100644
--- a/src/client/executor/tasks.rs
+++ b/src/client/executor/tasks.rs
@@ -1,6 +1,6 @@
pub(crate) struct Task {
pub name: &'static str,
- pub exec: fn(&[&str]) -> Result<String, String>,
+ pub exec: fn(&[String]) -> Result<String, String>,
}
pub(crate) const TASKS: &[Task] = &[
@@ -14,14 +14,14 @@ pub(crate) const TASKS: &[Task] = &[
},
];
-fn no_op(_: &[&str]) -> Result<String, String> {
+fn no_op(_: &[String]) -> Result<String, String> {
Ok("".to_string())
}
-fn exec(cmds: &[&str]) -> Result<String, String> {
+fn exec(cmds: &[String]) -> Result<String, String> {
use std::process::Command;
// TODO: fmt and add exit code, and add support for both stdout and stderr, and support for no output
- match Command::new(cmds[0]).args(&cmds[1..]).output() {
+ match Command::new(cmds[0].as_str()).args(&cmds[1..]).output() {
Ok(o) => {
if o.status.success() {
Ok(String::from_utf8(o.stdout)
@@ -37,8 +37,9 @@ fn exec(cmds: &[&str]) -> Result<String, String> {
}
}
+#[derive(Debug)]
pub(crate) enum IntoTaskErr {
- NotFound,
+ NotFound(String),
}
pub(crate) trait IntoTask {
@@ -52,7 +53,7 @@ impl IntoTask for String {
return Ok(task);
}
}
- Err(IntoTaskErr::NotFound)
+ Err(IntoTaskErr::NotFound(self))
}
}
@@ -63,6 +64,6 @@ impl IntoTask for &str {
return Ok(task);
}
}
- Err(IntoTaskErr::NotFound)
+ Err(IntoTaskErr::NotFound(self.to_string()))
}
}