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