From 3b27ce15cace19804031024f286754aedf86205e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 13 Sep 2025 22:10:20 +0800 Subject: feat: `executor`, executs `tasks` --- src/client/executor.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/client/executor.rs') 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 { - task: T, +struct Executor<'a> { + task: &'a Task, + args: Box<[&'a str]>, + output: Option>, } -impl Executor { - // fn new(args: &str) -> Self { - // // exe(parse()) - // } +impl<'a> Executor<'a> { + fn new(task: impl IntoTask, args: &'a str) -> Result { + let task = task.into_task()?; + Ok(Self { + task: task, + args: Box::new([args]), + output: None, + }) + } - // IntoTask like IntoUrl + fn run(&mut self) -> Option<&Result> { + self.output = Some((self.task.exec)(&self.args)); + self.output.as_ref() + } } -- cgit v1.2.3