Add the silent flag to the install command.
This commit is contained in:
parent
dff366f9a0
commit
87c53d5e09
|
@ -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 {
|
||||||
println!(
|
if !silent {
|
||||||
"{:?} exists, use --overwrite to replace the existing file",
|
println!(
|
||||||
hook_path
|
"{:?} exists, use --overwrite to replace the existing file",
|
||||||
);
|
hook_path
|
||||||
|
);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue