term, cli, remote-helper: Status Symbols

Symbols signaling status of a process and similar are duplicated in
three different crates. Also two different symbols to signal success are
used:

  1. ✓ (      Check Mark, U+2713)
  2. ✔ (Heavy Check Mark, U+2714)

Work against that by referring to `radicle-term` from the other crates.
This commit is contained in:
Lorenz Leutgeb 2025-08-13 09:48:48 +02:00 committed by Fintan Halpenny
parent 1cd3ad0784
commit c089727e90
10 changed files with 45 additions and 40 deletions

View File

@ -79,8 +79,8 @@ $ rad patch --merged
╭─────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Reviews Head + - Updated │
├─────────────────────────────────────────────────────────────────────────────┤
[ ... ] Second change alice (you) - daf349f +0 -0 now │
[ ... ] First change alice (you) - 20aa5dd +0 -0 now │
[ ... ] Second change alice (you) - daf349f +0 -0 now │
[ ... ] First change alice (you) - 20aa5dd +0 -0 now │
╰─────────────────────────────────────────────────────────────────────────────╯
$ rad patch show 696ec5508494692899337afe6713fe1796d0315c
╭────────────────────────────────────────────────────────────────╮
@ -158,6 +158,6 @@ $ rad patch --all
│ ● ID Title Author Reviews Head + - Updated │
├─────────────────────────────────────────────────────────────────────────────┤
│ ● 356f738 Second change alice (you) - daf349f +0 -0 now │
696ec55 First change alice (you) - 20aa5dd +0 -0 now │
696ec55 First change alice (you) - 20aa5dd +0 -0 now │
╰─────────────────────────────────────────────────────────────────────────────╯
```

View File

@ -206,7 +206,7 @@ $ rad patch list
╭─────────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Reviews Head + - Updated │
├─────────────────────────────────────────────────────────────────────────────────────────┤
│ ● aa45913 Define power requirements alice (you) 27857ec +0 -0 now │
│ ● aa45913 Define power requirements alice (you) 27857ec +0 -0 now │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
```

View File

@ -588,7 +588,7 @@ fn print_meta(revision: &Revision, previous: &Doc, profile: &Profile) -> anyhow:
for id in accepted {
let author = term::format::Author::new(&id, profile);
signatures.push([
term::format::positive("").into(),
term::PREFIX_SUCCESS.into(),
id.to_string().into(),
author.alias().unwrap_or_default(),
author.you().unwrap_or_default(),
@ -597,7 +597,7 @@ fn print_meta(revision: &Revision, previous: &Doc, profile: &Profile) -> anyhow:
for id in rejected {
let author = term::format::Author::new(&id, profile);
signatures.push([
term::format::negative("").into(),
term::PREFIX_ERROR.into(),
id.to_string().into(),
author.alias().unwrap_or_default(),
author.you().unwrap_or_default(),

View File

@ -412,15 +412,15 @@ fn state_initial() -> term::Paint<String> {
}
fn state_attempted() -> term::Paint<String> {
term::format::yellow("!".to_string())
term::PREFIX_WARNING.into()
}
fn state_connected() -> term::Paint<String> {
term::format::positive("".to_string())
term::PREFIX_SUCCESS.into()
}
fn state_disconnected() -> term::Paint<String> {
term::format::negative("".to_string())
term::PREFIX_ERROR.into()
}
fn link_direction_label() -> term::Paint<String> {

View File

@ -142,7 +142,7 @@ pub fn row(
patch::State::Open { .. } => term::format::positive("").into(),
patch::State::Archived => term::format::yellow("").into(),
patch::State::Draft => term::format::dim("").into(),
patch::State::Merged { .. } => term::format::primary("").into(),
patch::State::Merged { .. } => term::PREFIX_SUCCESS.into(),
},
term::format::tertiary(term::format::cob(id)).into(),
term::format::default(patch.title().to_owned()).into(),

View File

@ -341,8 +341,8 @@ pub mod patch {
pub fn verdict(v: Option<Verdict>) -> term::Paint<String> {
match v {
Some(Verdict::Accept) => term::format::positive("".to_string()),
Some(Verdict::Reject) => term::format::negative("".to_string()),
Some(Verdict::Accept) => term::PREFIX_SUCCESS.into(),
Some(Verdict::Reject) => term::PREFIX_ERROR.into(),
None => term::format::dim("-".to_string()),
}
}

View File

@ -290,8 +290,8 @@ impl Update<'_> {
Update::Reviewed { review } => {
let verdict = review.verdict();
let verdict_symbol = match verdict {
Some(Verdict::Accept) => term::format::positive(""),
Some(Verdict::Reject) => term::format::negative(""),
Some(Verdict::Accept) => term::PREFIX_SUCCESS,
Some(Verdict::Reject) => term::PREFIX_ERROR,
None => term::format::dim(""),
};
let verdict_verb = match verdict {
@ -310,7 +310,7 @@ impl Update<'_> {
Update::Merged { author, merge } => {
let (alias, nid) = author.labels();
term::Line::spaced([
term::format::primary("").bold().into(),
term::PREFIX_SUCCESS.bold().into(),
term::format::default("merged by").into(),
alias,
nid,

View File

@ -390,7 +390,7 @@ pub fn run(
let print_update = || {
eprintln!(
"{} Canonical reference {} updated to target {kind} {}",
term::format::positive(""),
term::PREFIX_SUCCESS,
term::format::secondary(refname),
term::format::secondary(oid),
)
@ -530,7 +530,7 @@ where
eprintln!(
"{} Patch {} {action}",
term::format::positive(""),
term::PREFIX_SUCCESS,
term::format::tertiary(patch),
);
@ -630,7 +630,7 @@ where
eprintln!(
"{} Patch {} updated to revision {}",
term::format::positive(""),
term::PREFIX_SUCCESS,
term::format::tertiary(term::format::cob(&patch_id)),
term::format::dim(revision.id())
);
@ -745,13 +745,13 @@ where
Ok(()) => {
eprintln!(
"{} Patch {} reverted at revision {}",
term::format::yellow("!"),
term::PREFIX_WARNING,
term::format::tertiary(&id),
term::format::dim(term::format::oid(*revision_id)),
);
}
Err(e) => {
eprintln!("{} Error reverting patch {id}: {e}", term::ERROR_PREFIX);
eprintln!("{} Error reverting patch {id}: {e}", term::PREFIX_ERROR);
}
}
break;
@ -833,13 +833,13 @@ where
if revision == latest {
eprintln!(
"{} Patch {} merged",
term::format::positive(""),
term::PREFIX_SUCCESS,
term::format::tertiary(merged.patch)
);
} else {
eprintln!(
"{} Patch {} merged at revision {}",
term::format::positive(""),
term::PREFIX_SUCCESS,
term::format::tertiary(merged.patch),
term::format::dim(term::format::oid(revision)),
);

View File

@ -17,9 +17,14 @@ use crate::{style, Paint, Size};
pub use inquire;
pub use inquire::Select;
pub const ERROR_PREFIX: Paint<&str> = Paint::red("");
pub const ERROR_HINT_PREFIX: Paint<&str> = Paint::yellow("✗ Hint:");
pub const WARNING_PREFIX: Paint<&str> = Paint::yellow("!");
pub(crate) const SYMBOL_ERROR: &str = "";
pub(crate) const SYMBOL_SUCCESS: &str = "";
pub(crate) const SYMBOL_WARNING: &str = "!";
pub const PREFIX_ERROR: Paint<&str> = Paint::red(SYMBOL_ERROR);
pub const PREFIX_SUCCESS: Paint<&str> = Paint::green(SYMBOL_SUCCESS);
pub const PREFIX_WARNING: Paint<&str> = Paint::yellow(SYMBOL_WARNING);
pub const TAB: &str = " ";
/// Passphrase input.
@ -29,15 +34,15 @@ pub type Passphrase = Zeroizing<String>;
pub static CONFIG: LazyLock<RenderConfig> = LazyLock::new(|| RenderConfig {
prompt: StyleSheet::new().with_fg(Color::LightCyan),
prompt_prefix: Styled::new("?").with_fg(Color::LightBlue),
answered_prompt_prefix: Styled::new("").with_fg(Color::LightGreen),
answered_prompt_prefix: Styled::new(SYMBOL_SUCCESS).with_fg(Color::LightGreen),
answer: StyleSheet::new(),
highlighted_option_prefix: Styled::new("").with_fg(Color::LightYellow),
highlighted_option_prefix: Styled::new(SYMBOL_SUCCESS).with_fg(Color::LightYellow),
selected_option: Some(StyleSheet::new().with_fg(Color::LightYellow)),
option: StyleSheet::new(),
help_message: StyleSheet::new().with_fg(Color::DarkGrey),
default_value: StyleSheet::new().with_fg(Color::LightBlue),
error_message: ErrorMessageRenderConfig::default_colored()
.with_prefix(Styled::new("").with_fg(Color::LightRed)),
.with_prefix(Styled::new(SYMBOL_ERROR).with_fg(Color::LightRed)),
..RenderConfig::default_colored()
});
@ -87,7 +92,7 @@ pub use success;
pub use tip;
pub fn success_args<W: io::Write>(w: &mut W, args: fmt::Arguments) {
writeln!(w, "{} {args}", Paint::green("")).ok();
writeln!(w, "{PREFIX_SUCCESS} {args}").ok();
}
pub fn tip_args(args: fmt::Arguments) {
@ -99,7 +104,7 @@ pub fn tip_args(args: fmt::Arguments) {
}
pub fn notice_args<W: io::Write>(w: &mut W, args: fmt::Arguments) {
writeln!(w, "{} {args}", Paint::new("!").dim()).ok();
writeln!(w, "{} {args}", Paint::new(SYMBOL_WARNING).dim()).ok();
}
pub fn columns() -> Option<usize> {
@ -167,7 +172,7 @@ pub fn manual(name: &str) -> io::Result<process::ExitStatus> {
pub fn usage(name: &str, usage: &str) {
println!(
"{} {}\n{}",
ERROR_PREFIX,
PREFIX_ERROR,
Paint::red(format!("Error: rad-{name}: invalid usage")),
Paint::red(prefixed(TAB, usage)).dim()
);
@ -188,17 +193,17 @@ pub fn subcommand(msg: impl fmt::Display) {
pub fn warning(warning: impl fmt::Display) {
println!(
"{} {} {warning}",
WARNING_PREFIX,
PREFIX_WARNING,
Paint::yellow("Warning:").bold(),
);
}
pub fn error(error: impl fmt::Display) {
println!("{ERROR_PREFIX} {} {error}", Paint::red("Error:"));
println!("{PREFIX_ERROR} {} {error}", Paint::red("Error:"));
}
pub fn hint(hint: impl fmt::Display) {
println!("{ERROR_HINT_PREFIX} {}", format::hint(hint));
println!("{}", format::hint(format!("{SYMBOL_ERROR} Hint: {hint}")));
}
pub fn ask<D: fmt::Display>(prompt: D, default: bool) -> bool {

View File

@ -3,7 +3,7 @@ use std::mem::ManuallyDrop;
use std::sync::{Arc, Mutex};
use std::{fmt, io, thread, time};
use crate::io::{ERROR_PREFIX, WARNING_PREFIX};
use crate::io::{PREFIX_ERROR, PREFIX_WARNING};
use crate::Paint;
/// How much time to wait between spinner animation updates.
@ -161,7 +161,7 @@ pub fn spinner_to(
write!(animation, "\r{CLEAR_UNTIL_NEWLINE}").ok();
writeln!(
completion,
"{ERROR_PREFIX} {} {}",
"{PREFIX_ERROR} {} {}",
&progress.message,
Paint::red("<canceled>")
)
@ -190,7 +190,7 @@ pub fn spinner_to(
message,
} => {
write!(animation, "\r{CLEAR_UNTIL_NEWLINE}").ok();
writeln!(completion, "{} {message}", Paint::green("")).ok();
writeln!(completion, "{} {message}", super::PREFIX_SUCCESS).ok();
break;
}
Progress {
@ -200,7 +200,7 @@ pub fn spinner_to(
write!(animation, "\r{CLEAR_UNTIL_NEWLINE}").ok();
writeln!(
completion,
"{ERROR_PREFIX} {message} {}",
"{PREFIX_ERROR} {message} {}",
Paint::red("<canceled>")
)
.ok();
@ -211,7 +211,7 @@ pub fn spinner_to(
message,
} => {
write!(animation, "\r{CLEAR_UNTIL_NEWLINE}").ok();
writeln!(completion, "{WARNING_PREFIX} {message}").ok();
writeln!(completion, "{PREFIX_WARNING} {message}").ok();
break;
}
Progress {
@ -219,7 +219,7 @@ pub fn spinner_to(
message,
} => {
write!(animation, "\r{CLEAR_UNTIL_NEWLINE}").ok();
writeln!(completion, "{ERROR_PREFIX} {message}").ok();
writeln!(completion, "{PREFIX_ERROR} {message}").ok();
break;
}
}