diff --git a/src/commands/scripts.rs b/src/commands/scripts.rs index afaf4e0..ce2c0ed 100644 --- a/src/commands/scripts.rs +++ b/src/commands/scripts.rs @@ -1,4 +1,4 @@ -use std::process::Stdio; +use std::process::{Stdio, exit}; use clap::Args; @@ -12,10 +12,12 @@ use crate::{models::package::PackageConfigExtensions, utils::ndk}; use super::Command; #[derive(Args)] +#[command(disable_help_flag = true)] pub struct ScriptsCommand { script: String, - args: Option>, + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, } impl Command for ScriptsCommand { @@ -30,13 +32,11 @@ impl Command for ScriptsCommand { bail!("Could not find script {}", self.script); } - let supplied_args = self.args.unwrap_or_default(); - let Some(script) = script else { return Ok(()); }; - invoke_script(script, &supplied_args, &package)?; + invoke_script(script, &self.args, &package)?; Ok(()) } @@ -92,7 +92,10 @@ pub fn invoke_script( c.env("ANDROID_NDK_HOME", path); } - c.spawn()?.wait()?.exit_ok()?; + let code = c.spawn()?.wait()?.code().unwrap_or_else(|| 1); + if code != 0 { + exit(code); + } } Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index b098f91..7bbc9b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![feature(exit_status_error)] #![feature(if_let_guard)] #![feature(path_add_extension)] +#![feature(path_is_empty)] #[cfg(feature = "cli")] pub mod commands; diff --git a/src/main.rs b/src/main.rs index ece5a9e..8e3cb18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ #![feature(exit_status_error)] #![feature(if_let_guard)] #![feature(path_add_extension)] +#![feature(path_is_empty)] use std::io;