#[task]Expand description
Attribute macro for defining a rnme task.
Supports both sync and async task functions. The function is wrapped
to produce the TaskFn signature: fn(&TaskContext, &[String]) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>.
The generated TaskDef includes group: __RNME_GROUP and
dir: __RNME_DIR. Both constants are injected by the code generator at
compile time. For standalone usage (tests, examples), define
const __RNME_GROUP: &str = ""; and const __RNME_DIR: &str = "";
manually — the empty __RNME_DIR makes ctx.spawn inherit the
process cwd as before.
If __RNME_GROUP / __RNME_DIR aren’t in scope at the expansion site,
the macro fails to compile with cannot find value __RNME_GROUP in this scope. To declare reusable tasks in a regular library crate
(one without a RUNME.rs), use task_template instead and have
the consumer site stamp it with import_task.
The task description is taken from the function’s /// doc comments.
§Three argument forms
Form 1: Zero args
/// Build the project
#[rnme::task]
async fn build(ctx: &TaskContext) -> TaskResult {
ctx.exec("cargo build").await?.ok()?;
Ok(())
}Form 2: Simple args (auto-generates clap from params)
/// Deploy to environment
#[rnme::task]
async fn deploy(ctx: &TaskContext, env: String, port: u16, verbose: bool) -> TaskResult {
// env -> --env <value>, port -> --port <value>, verbose -> --verbose (flag)
Ok(())
}Form 3: Parser struct (single non-primitive param, uses clap derive)
#[derive(clap::Parser)]
struct DeployArgs {
#[arg(long)]
env: String,
}
/// Deploy to environment
#[rnme::task]
async fn deploy(ctx: &TaskContext, args: DeployArgs) -> TaskResult {
Ok(())
}