From 566713bf6b26223cae7e4576f0c8e48cb7882c44 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 23 Jan 2024 10:37:47 +0900 Subject: [PATCH] cli: colorize choices of prev/next commits --- cli/src/commands/next.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/src/commands/next.rs b/cli/src/commands/next.rs index ef6613dad..1b12887d8 100644 --- a/cli/src/commands/next.rs +++ b/cli/src/commands/next.rs @@ -70,18 +70,17 @@ pub fn choose_commit<'a>( commits: &'a [Commit], ) -> Result<&'a Commit, CommandError> { writeln!(ui.stdout(), "ambiguous {cmd} commit, choose one to target:")?; + let mut formatter = ui.stdout_formatter(); let mut choices: Vec = Default::default(); for (i, commit) in commits.iter().enumerate() { - writeln!( - ui.stdout(), - "{}: {}", - i + 1, - workspace_command.format_commit_summary(commit) - )?; + write!(formatter, "{}: ", i + 1)?; + workspace_command.write_commit_summary(formatter.as_mut(), commit)?; + writeln!(formatter)?; choices.push(format!("{}", i + 1)); } - writeln!(ui.stdout(), "q: quit the prompt")?; + writeln!(formatter, "q: quit the prompt")?; choices.push("q".to_string()); + drop(formatter); let choice = ui.prompt_choice( "enter the index of the commit you want to target",