diff --git a/.vscode/launch.json b/.vscode/launch.json index f053de9d..9e677a59 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -32,7 +32,7 @@ { "type": "promptString", "id": "step", - "description": "step nname", + "description": "step name", } ] } diff --git a/src/config.rs b/src/config.rs index 844e4866..638e1a56 100644 --- a/src/config.rs +++ b/src/config.rs @@ -397,6 +397,10 @@ pub struct CommandLineArgs { #[clap(long = "only", arg_enum)] only: Vec, + /// Run only specific custom commands + #[clap(long = "custom-commands")] + custom_commands: Vec, + /// Set environment variables #[clap(long = "env")] env: Vec, @@ -876,4 +880,12 @@ impl Config { pub fn display_time(&self) -> bool { self.config_file.display_time.unwrap_or(true) } + + pub fn should_run_custom_command(&self, name: &str) -> bool { + if self.opt.custom_commands.is_empty() { + return true; + } + + self.opt.custom_commands.iter().any(|s| s == name) + } } diff --git a/src/main.rs b/src/main.rs index 9db1d12a..c06d4a94 100644 --- a/src/main.rs +++ b/src/main.rs @@ -360,9 +360,11 @@ fn run() -> Result<()> { if let Some(commands) = config.commands() { for (name, command) in commands { - runner.execute(Step::CustomCommands, name, || { - generic::run_custom_command(name, command, &ctx) - })?; + if config.should_run_custom_command(name) { + runner.execute(Step::CustomCommands, name, || { + generic::run_custom_command(name, command, &ctx) + })?; + } } }