Add the silent flag to the install command.

This commit is contained in:
Bauke 2024-01-24 18:27:32 +01:00
parent dff366f9a0
commit 87c53d5e09
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
3 changed files with 12 additions and 5 deletions

View File

@ -15,6 +15,7 @@ use crate::{cli::InstallArgs, DEFAULT_TEMPLATE, HOOK_TYPES};
/// The `install` subcommand.
pub fn hooked_install(config: Config, args: InstallArgs) -> Result<()> {
let silent = args.silent;
let git_hooks_dir = PathBuf::from(".git/hooks/");
if !git_hooks_dir.exists() {
return Err(eyre!("The \".git/hooks/\" directory does not exist"));
@ -28,10 +29,12 @@ pub fn hooked_install(config: Config, args: InstallArgs) -> Result<()> {
let hook_path = git_hooks_dir.join(hook_type);
if hook_path.exists() && !args.overwrite {
println!(
"{:?} exists, use --overwrite to replace the existing file",
hook_path
);
if !silent {
println!(
"{:?} exists, use --overwrite to replace the existing file",
hook_path
);
}
continue;
}

View File

@ -56,6 +56,10 @@ pub struct InstallArgs {
/// Overwrite existing files.
#[clap(long)]
pub overwrite: bool,
/// Don't output any information.
#[clap(long)]
pub silent: bool,
}
/// The `uninstall` subcommand arguments.

View File

@ -28,6 +28,6 @@ mkShell rec {
cargo install --path hooked-cli --root $out
fi
hooked install
hooked install --silent
'';
}