Skip to main content

Task

Struct Task 

Source
pub struct Task {
    pub name: String,
    pub description: String,
    pub lang: String,
    pub script: String,
    pub opts: Vec<String>,
    pub env: Vec<(String, String)>,
    pub args: Vec<Arg>,
    pub requires: Vec<String>,
    pub agent_allow: bool,
}
Expand description

One task: a named script with its interpreter and metadata.

Fields§

§name: String

The heading text (the command name).

§description: String

Prose in the task body that is not a recognized Key: value line.

§lang: String

The fenced block’s info-string language (sh, zsh, python, …); empty means an unlabeled fence (treated as sh).

§script: String

The script (the fenced block’s contents), verbatim.

§opts: Vec<String>

Opts: carries per-task boolean flags, space-separated. The only flag today is inherit-cwd: run the task in the directory mdtask was invoked from, rather than the default (the directory of the task file that defines it). Use it for a task that operates on a path relative to where you are (a carry-around task such as pdf a-note.md). An unrecognized flag is recorded as a warning and otherwise ignored. See TaskFile::invocation.

§env: Vec<(String, String)>

Env: adds extra environment for this task.

§args: Vec<Arg>

Args: declares positional arguments in just’s syntax. A bare name is required, name='default' is optional, and a trailing *name is variadic (it collects the rest, space-joined). Each one is substituted as {{ name }} in the script and also exported as $name. Note that {{ name }} is raw text substitution, spliced in before the interpreter parses the script, so {{ name }} is NOT injection-safe for untrusted values in any language. The safe form is to read the value from the environment, never to template it: "$name" in a shell, os.environ["name"] in Python, process.env.name in Node, and so on. Reserve {{ }} for developer-authored templates.

§requires: Vec<String>

Requires: names the tasks this one depends on. mdtask-core does not run them (execution stays the caller’s), but dependency_order resolves the transitive run order (deps first, cycle and typo detected) so a caller can run each in turn. The mdtask CLI does exactly that.

§agent_allow: bool

Agent: allow opts a task in to being listed and run by an MCP or agent surface. It is advisory data: nothing in mdtask-core’s execution path checks it. A caller exposing tasks to an agent must filter with TaskFile::agent_tasks (off by default), which is the enforcement point. The flag alone enforces nothing.

Implementations§

Source§

impl Task

Source

pub fn inherits_cwd(&self) -> bool

Whether this task opted into Opts: inherit-cwd: run it in the invocation directory rather than the default (the task file’s own directory).

Source

pub fn script_arg_templates(&self) -> Vec<&str>

The declared argument names this task interpolates into its script via {{ arg }} (raw text substitution, spliced in before the interpreter parses the script). Because it is not quoted, each of these is an injection point for an untrusted argument value, in any language. A surface that runs a task with caller-controlled argument values (an agent/MCP surface) should refuse a task that has any; the author should read the value from the environment instead ("$arg", os.environ["arg"], …). Empty for a task that reads its args from the environment, the safe form. See TaskFile::invocation.

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Task

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Task

Source§

fn default() -> Task

Returns the “default value” for a type. Read more
Source§

impl Eq for Task

Source§

impl PartialEq for Task

Source§

fn eq(&self, other: &Task) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Task

Auto Trait Implementations§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnsafeUnpin for Task

§

impl UnwindSafe for Task

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.