Skip to content

Commit

Permalink
fix(args): mutually exclusive hook and all
Browse files Browse the repository at this point in the history
As the "all" argument doesn't do anything in hook mode, we might as well just make them mutually exclusive for more clarity.
  • Loading branch information
cococonscious committed Dec 17, 2024
1 parent 46637f8 commit 74edf6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
17 changes: 17 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,23 @@ fn test_empty_repository_error() -> Result<(), Box<dyn Error>> {
Ok(())
}

#[test]
fn test_all_hook_exclusive_error() -> Result<(), Box<dyn Error>> {
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<dyn Error>> {
fn run_for(shell: &'static str, containing: &'static str) -> Result<(), Box<dyn Error>> {
Expand Down

0 comments on commit 74edf6b

Please sign in to comment.