diff --git a/src/bin/main.rs b/src/bin/main.rs index 6d1c592..eddb6ba 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -61,7 +61,8 @@ struct Args { #[arg( long, - help = "Run as a git hook, writing the commit message to COMMIT_EDITMSG instead of committing" + help = "Run as a git hook, writing the commit message to COMMIT_EDITMSG instead of committing", + conflicts_with = "all" )] hook: bool, diff --git a/tests/integration.rs b/tests/integration.rs index 0643ee1..e96eb33 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -335,6 +335,23 @@ fn test_empty_repository_error() -> Result<(), Box> { Ok(()) } +#[test] +fn test_all_hook_exclusive_error() -> Result<(), Box> { + let bin_path = assert_cmd::cargo::cargo_bin("koji"); + + let mut cmd = Command::new(bin_path); + cmd.arg("--hook"); + cmd.arg("--all"); + + let cmd_out = cmd.output()?; + let stderr_out = String::from_utf8(cmd_out.stderr)?; + + assert!(!cmd_out.status.success()); + assert!(stderr_out.contains("the argument '--hook' cannot be used with '--all'")); + + Ok(()) +} + #[test] fn test_completion_scripts_success() -> Result<(), Box> { fn run_for(shell: &'static str, containing: &'static str) -> Result<(), Box> {