Skip to main content

cli/commands/
task.rs

1use clap::{Args, Subcommand, ValueHint};
2use std::path::PathBuf;
3
4#[derive(Subcommand, Debug)]
5pub enum TaskCommands {
6    /// Save a command as a named task
7    Save {
8        /// Task name (letters, numbers, dots, dashes, underscores)
9        name: String,
10        /// Replace an existing task with the same name
11        #[arg(long)]
12        force: bool,
13        /// Always run the task from this directory
14        #[arg(long, value_hint = ValueHint::DirPath)]
15        cwd: Option<PathBuf>,
16        /// Command and arguments to save (after `--`)
17        #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
18        command: Vec<String>,
19    },
20    /// Run a saved task in the current directory
21    Run(TaskRunCommand),
22    /// List saved tasks
23    List,
24    /// Show a saved task's full command
25    Info {
26        /// Task name
27        name: String,
28    },
29    /// Delete a saved task
30    Delete {
31        /// Task name
32        name: String,
33    },
34}
35
36#[derive(Args, Debug)]
37pub struct TaskRunCommand {
38    /// Task name
39    pub name: String,
40    /// Extra arguments appended to the saved command (after `--`)
41    #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
42    pub extra: Vec<String>,
43}