Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/cli/issue/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anyhow::{Context, Result, bail};

use crate::api::client::JiraClient;
use crate::cli::{IssueCommand, OutputFormat};
use crate::error::JrError;
use crate::output;
use crate::partial_match::{self, MatchResult};

Expand Down Expand Up @@ -65,11 +66,12 @@ pub(super) async fn handle_link(
MatchResult::ExactMultiple(name) => name,
MatchResult::Ambiguous(matches) => {
if no_input {
bail!(
return Err(JrError::UserError(format!(
"Ambiguous link type \"{}\". Matches: {}",
link_type_name,
matches.join(", ")
);
))
.into());
}
let selection = dialoguer::Select::new()
.with_prompt(format!("Multiple types match \"{link_type_name}\""))
Expand Down Expand Up @@ -135,11 +137,12 @@ pub(super) async fn handle_unlink(
MatchResult::ExactMultiple(name) => name,
MatchResult::Ambiguous(matches) => {
if no_input {
bail!(
return Err(JrError::UserError(format!(
"Ambiguous link type \"{}\". Matches: {}",
type_name,
matches.join(", ")
);
))
.into());
}
let selection = dialoguer::Select::new()
.with_prompt(format!("Multiple types match \"{type_name}\""))
Expand Down
5 changes: 3 additions & 2 deletions src/cli/issue/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ pub(super) async fn handle_move(
}
MatchResult::Ambiguous(matches) => {
if no_input {
bail!(
return Err(JrError::UserError(format!(
"Ambiguous transition \"{}\". Matches: {}",
target_status,
matches.join(", ")
);
))
.into());
}
// Interactive disambiguation
eprintln!(
Expand Down
12 changes: 4 additions & 8 deletions tests/issue_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1742,13 +1742,10 @@ async fn test_move_single_substring_rejected_no_input() {
!output.status.success(),
"Expected failure on ambiguous substring, stderr: {stderr}"
);
// workflow.rs uses `anyhow::bail!` which doesn't inject a JrError into
// the cause chain → main.rs falls back to exit 1. Pinning this lets a
// future refactor to JrError::UserError (exit 64) flag the test for review.
assert_eq!(
output.status.code(),
Some(1),
"Ambiguous transition currently exits 1 via anyhow::bail!, got: {:?}",
Some(64),
"Ambiguous transition should exit 64 (UserError), got: {:?}",
output.status.code()
);
assert!(
Expand Down Expand Up @@ -1802,11 +1799,10 @@ async fn test_link_single_substring_rejected_no_input() {
!output.status.success(),
"Expected failure on ambiguous substring, stderr: {stderr}"
);
// links.rs uses `anyhow::bail!` → exit 1 (see move test for rationale).
assert_eq!(
output.status.code(),
Some(1),
"Ambiguous link type currently exits 1 via anyhow::bail!, got: {:?}",
Some(64),
"Ambiguous link type should exit 64 (UserError), got: {:?}",
output.status.code()
);
assert!(
Expand Down