Skip to main content

Task

Struct Task 

Source
pub struct Task {
    pub name: String,
    pub description: String,
    pub lang: String,
    pub script: String,
    pub dir: Option<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.

§dir: Option<String>

Dir: overrides the working directory. When absent, a task runs in the invocation directory, not where the task file lives, so an inherited or global task acts on your current project. A relative value resolves against the task file’s own directory (Dir: . pins the task there); an absolute value is used verbatim. It may contain {{ arg }}, and resolution is purely lexical, with no filesystem access. 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, applied before the shell parses the script, so "{{ name }}" is NOT injection-safe for untrusted values. Prefer "$name", which the shell quotes, and reserve {{ }} for Dir: and 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 script_arg_templates(&self) -> Vec<&str>

The declared argument names this task interpolates into its script via {{ arg }} (raw text substitution, applied before the shell parses the script). Because {{ }} is not shell-quoted, each of these is a shell injection point for an untrusted argument value. A surface that runs a task with caller-controlled argument values (an agent/MCP surface) should refuse a task that has any, and the author should switch to "$arg", which the shell quotes. Empty for a task that only uses $arg (the safe form) or uses {{ }} solely in Dir: (which is not the script). 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.