diff options
Diffstat (limited to 'src/client/executor')
| -rw-r--r-- | src/client/executor/tasks.rs | 15 |
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())) } } |
