1use crate::{Arguments, Context, Parameter, Result, Value};
2
3pub struct Task {
5 pub(crate) name: String,
6 pub(crate) description: String,
7 pub(crate) parameters: Vec<Parameter>,
8 pub(crate) invoke: fn(&mut Context, &Arguments) -> Result<Value>,
9 pub(crate) handles_output: bool,
10 pub(crate) builtin: bool,
11}
12
13impl Task {
14 pub fn new(
15 name: impl Into<String>,
16 description: impl Into<String>,
17 parameters: Vec<Parameter>,
18 invoke: fn(&mut Context, &Arguments) -> Result<Value>,
19 ) -> Self {
20 Self {
21 name: name.into(),
22 description: description.into(),
23 parameters,
24 invoke,
25 handles_output: false,
26 builtin: false,
27 }
28 }
29
30 pub fn handles_output(mut self) -> Self {
32 self.handles_output = true;
33 self
34 }
35
36 pub(crate) fn builtin(mut self) -> Self {
37 self.builtin = true;
38 self
39 }
40
41 pub fn name(&self) -> &str {
42 &self.name
43 }
44 pub fn description(&self) -> &str {
45 &self.description
46 }
47 pub fn parameters(&self) -> &[Parameter] {
48 &self.parameters
49 }
50 pub fn produces_output(&self) -> bool {
51 self.handles_output
52 }
53}