Add --custom-command (#927)

* Add --custom-command
Fixes #922

* fix
This commit is contained in:
Roey Darwish Dror
2022-05-07 15:25:51 +03:00
committed by GitHub
parent fdf03f6548
commit c166d51fb8
3 changed files with 18 additions and 4 deletions

2
.vscode/launch.json vendored
View File

@@ -32,7 +32,7 @@
{
"type": "promptString",
"id": "step",
"description": "step nname",
"description": "step name",
}
]
}

View File

@@ -397,6 +397,10 @@ pub struct CommandLineArgs {
#[clap(long = "only", arg_enum)]
only: Vec<Step>,
/// Run only specific custom commands
#[clap(long = "custom-commands")]
custom_commands: Vec<String>,
/// Set environment variables
#[clap(long = "env")]
env: Vec<String>,
@@ -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)
}
}

View File

@@ -360,11 +360,13 @@ fn run() -> Result<()> {
if let Some(commands) = config.commands() {
for (name, command) in commands {
if config.should_run_custom_command(name) {
runner.execute(Step::CustomCommands, name, || {
generic::run_custom_command(name, command, &ctx)
})?;
}
}
}
#[cfg(target_os = "linux")]
{