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. /// The `install` subcommand.
pub fn hooked_install(config: Config, args: InstallArgs) -> Result<()> { pub fn hooked_install(config: Config, args: InstallArgs) -> Result<()> {
let silent = args.silent;
let git_hooks_dir = PathBuf::from(".git/hooks/"); let git_hooks_dir = PathBuf::from(".git/hooks/");
if !git_hooks_dir.exists() { if !git_hooks_dir.exists() {
return Err(eyre!("The \".git/hooks/\" directory does not exist")); 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); let hook_path = git_hooks_dir.join(hook_type);
if hook_path.exists() && !args.overwrite { if hook_path.exists() && !args.overwrite {
if !silent {
println!( println!(
"{:?} exists, use --overwrite to replace the existing file", "{:?} exists, use --overwrite to replace the existing file",
hook_path hook_path
); );
}
continue; continue;
} }

View File

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

View File

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