summaryrefslogtreecommitdiff
path: root/src/client/executor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/executor.rs')
-rw-r--r--src/client/executor.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/client/executor.rs b/src/client/executor.rs
index eee1b36..df22c57 100644
--- a/src/client/executor.rs
+++ b/src/client/executor.rs
@@ -1,15 +1,25 @@
-use crate::executor::tasks::Task;
+use crate::executor::tasks::{IntoTask, IntoTaskErr, Task};
mod tasks;
-struct Executor<T: Task> {
- task: T,
+struct Executor<'a> {
+ task: &'a Task,
+ args: Box<[&'a str]>,
+ output: Option<Result<String, String>>,
}
-impl<T: Task> Executor<T> {
- // fn new(args: &str) -> Self {
- // // exe(parse())
- // }
+impl<'a> Executor<'a> {
+ fn new(task: impl IntoTask, args: &'a str) -> Result<Self, IntoTaskErr> {
+ let task = task.into_task()?;
+ Ok(Self {
+ task: task,
+ args: Box::new([args]),
+ output: None,
+ })
+ }
- // IntoTask like IntoUrl
+ fn run(&mut self) -> Option<&Result<String, String>> {
+ self.output = Some((self.task.exec)(&self.args));
+ self.output.as_ref()
+ }
}