diff --git a/crates/cli/README.md b/crates/cli/README.md index 4fd2a04a45..8d71cafacd 100644 --- a/crates/cli/README.md +++ b/crates/cli/README.md @@ -40,7 +40,7 @@ SUBCOMMANDS: Generates stub PHP files for the extension $ cargo php install --help -cargo-php-install +cargo-php-install Installs the extension in the current PHP installation. @@ -71,8 +71,11 @@ OPTIONS: --release Whether to install the release version of the extension + --yes + Bypasses the confirmation prompt + $ cargo php remove --help -cargo-php-remove +cargo-php-remove Removes the extension in the current PHP installation. @@ -97,8 +100,11 @@ OPTIONS: Path to the Cargo manifest of the extension. Defaults to the manifest in the directory the command is called + --yes + Bypasses the confirmation prompt + $ cargo php stubs --help -cargo-php-stubs +cargo-php-stubs Generates stub PHP files for the extension. @@ -120,7 +126,7 @@ OPTIONS: --manifest Path to the Cargo manifest of the extension. Defaults to the manifest in the directory the command is called. - + This cannot be provided alongside the `ext` option, as that option provides a direct path to the extension shared library. diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index cbac73982a..c145bbdd99 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -105,6 +105,9 @@ struct Install { /// the directory the command is called. #[arg(long)] manifest: Option, + /// Whether to bypass the install prompt. + #[clap(long)] + yes: bool, } #[derive(Parser)] @@ -121,6 +124,9 @@ struct Remove { /// the directory the command is called. #[arg(long)] manifest: Option, + /// Whether to bypass the remove prompt. + #[clap(long)] + yes: bool, } #[cfg(not(windows))] @@ -172,12 +178,13 @@ impl Install { php_ini = Some(ini_path); } - if !Confirm::new() - .with_prompt(format!( - "Are you sure you want to install the extension `{}`?", - artifact.name - )) - .interact()? + if !self.yes + && !Confirm::new() + .with_prompt(format!( + "Are you sure you want to install the extension `{}`?", + artifact.name + )) + .interact()? { bail!("Installation cancelled."); } @@ -305,12 +312,13 @@ impl Remove { bail!("Unable to find extension installed."); } - if !Confirm::new() - .with_prompt(format!( - "Are you sure you want to remove the extension `{}`?", - artifact.name - )) - .interact()? + if !self.yes + && !Confirm::new() + .with_prompt(format!( + "Are you sure you want to remove the extension `{}`?", + artifact.name + )) + .interact()? { bail!("Installation cancelled."); } diff --git a/guide/src/cargo-php.md b/guide/src/cargo-php.md index d1640efcc4..147e8cc62f 100644 --- a/guide/src/cargo-php.md +++ b/guide/src/cargo-php.md @@ -84,7 +84,7 @@ personally recommend for use in Visual Studio Code). ```text $ cargo php stubs --help -cargo-php-stubs +cargo-php-stubs Generates stub PHP files for the extension. @@ -106,7 +106,7 @@ OPTIONS: --manifest Path to the Cargo manifest of the extension. Defaults to the manifest in the directory the command is called. - + This cannot be provided alongside the `ext` option, as that option provides a direct path to the extension shared library. @@ -130,7 +130,7 @@ so you are able to restore if you run into any issues. ```text $ cargo php install --help -cargo-php-install +cargo-php-install Installs the extension in the current PHP installation. @@ -164,6 +164,9 @@ OPTIONS: --release Whether to install the release version of the extension + + --yes + Bypasses the confirmation prompt ``` ## Extension Removal @@ -175,7 +178,7 @@ from your `php.ini` if present. ```text $ cargo php remove --help -cargo-php-remove +cargo-php-remove Removes the extension in the current PHP installation. @@ -203,6 +206,9 @@ OPTIONS: --manifest Path to the Cargo manifest of the extension. Defaults to the manifest in the directory the command is called + + --yes + Bypasses the confirmation prompt ``` [`cargo-php`]: https://crates.io/crates/cargo-php