1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! Terminal output helpers — colors, icons, and spinner.
//!
//! All user-visible formatting is defined here so the visual style stays
//! consistent across all four commands. Call sites import only what they need.
//!
//! ## Style guide
//!
//! | Category | Icon | Color | Use for |
//! |-----------|------|--------------|------------------------------------------------|
//! | Success | `✓` | Bold green | Operation completed successfully |
//! | Warning | `!` | Bold yellow | Non-fatal issue the user should read |
//! | Error | `✗` | Bold red | Validation failure (inline, before re-prompt) |
//! | Progress | — | Dimmed | In-flight operation ("Pushing…") |
//! | Tip | — | `Tip:` bold | Optional improvement hints |
//! | URL | — | Cyan | Git remote URLs |
//! | Command | — | Bold | `entangle <cmd>` references in text |
//! | Debug | — | Dimmed | `[debug]` diagnostic lines |
//!
//! ## Colors in tests
//!
//! Integration tests capture stdout via `Command::output()` which is not a TTY.
//! `owo-colors` still emits ANSI codes in this mode (always-on by default), but
//! test assertions use substring matching (`contains("✓")`, `contains("setup")`)
//! so the surrounding escape sequences are transparent. A future `NO_COLOR`
//! environment variable check can be added here centrally if needed.
//!
//! ## Spinner
//!
//! [`remote_check_spinner`] returns an `indicatif::ProgressBar` configured for
//! network-call feedback. In non-TTY environments (CI, piped output) indicatif
//! disables drawing automatically — no special-casing is needed in tests.
use ;
use OwoColorize;
use Duration;
// ---------------------------------------------------------------------------
// Inline message formatters
// ---------------------------------------------------------------------------
/// `✓ <msg>` — bold green. Use for completed operations.
/// `! <msg>` — bold yellow. Use for non-fatal warnings the user should note.
/// `✗ <msg>` — bold red. Use for inline validation errors before a re-prompt.
///
/// Does not exit the process. Fatal top-level errors are formatted by
/// [`error_prefix`] in `main.rs`.
/// Dimmed text. Use for in-flight progress messages ("Pushing…", "Checking…").
/// `Tip: <msg>` — `Tip:` is bold; message is normal weight.
///
/// Use for optional improvement hints (.gitignore, README.md suggestions).
/// Cyan text. Use for git remote URLs in output.
/// Bold text. Use for `entangle <cmd>` command references embedded in sentences.
///
/// Wraps the name in backtick-quotes so it reads naturally in plain text too:
/// `` `entangle shove` ``.
/// Dimmed `[debug]` tag. Use as a prefix on all `VerbosityLevel::Debug` lines.
/// Bold red `Error:`. Used by `main.rs` for the top-level error prefix.
// ---------------------------------------------------------------------------
// Spinner
// ---------------------------------------------------------------------------
/// Create a spinner for network operations (remote accessibility checks).
///
/// The spinner draws to stderr so it does not interfere with stdout. It will
/// self-disable in non-TTY environments (CI, piped output). Call
/// `spinner.finish_and_clear()` when the operation completes, then print the
/// result via `println!` / `vlog!` as normal.
///
/// ```rust,ignore
/// let sp = output::remote_check_spinner("Checking remote accessibility…");
/// let result = remote_validator(&origin_url, &mirror_url);
/// sp.finish_and_clear();
/// // … handle result
/// ```