refactor(cli): migrate all command modules from console::style to Theme
Replace all console::style() calls in command modules with the centralized Theme API and render:: utility functions. This ensures consistent color behavior across the entire CLI, proper NO_COLOR/--color never support via the LoreRenderer singleton, and eliminates duplicated formatting code. Changes per module: - count.rs: Theme for table headers, render::format_number replacing local duplicate. Removed local format_number implementation. - doctor.rs: Theme::success/warning/error for check status symbols and messages. Unicode escapes for check/warning/cross symbols. - drift.rs: Theme::bold/error/success for drift detection headers and status messages. - embed.rs: Compact output format — headline with count, zero-suppressed detail lines, 'nothing to embed' short-circuit for no-op runs. - generate_docs.rs: Same compact pattern — headline + detail + hint for next step. No-op short-circuit when regenerated==0. - ingest.rs: Theme for project summaries, sync status, dry-run preview. All console::style -> Theme replacements. - list.rs: Replace comfy-table with render::LoreTable for issue/MR listing. Remove local colored_cell, colored_cell_hex, format_relative_time, truncate_with_ellipsis, and format_labels (all moved to render.rs). - list_tests.rs: Update test assertions to use render:: functions. - search.rs: Add render_snippet() for FTS5 <mark> tag highlighting via Theme::bold().underline(). Compact result layout with type badges. - show.rs: Theme for entity detail views, delegate format_date and wrap_text to render module. - stats.rs: Section-based layout using render::section_divider. Compact middle-dot format for document counts. Color-coded embedding coverage percentage (green >=95%, yellow >=50%, red <50%). - sync.rs: Compact sync summary — headline with counts and elapsed time, zero-suppressed detail lines, visually prominent error-only section. - sync_status.rs: Theme for run history headers, removed local format_number duplicate. - timeline.rs: Theme for headers/footers, render:: for date/truncate, standard format! padding replacing console::pad_str. - who.rs: Theme for all expert/workload/active/overlap/review output modes, render:: for relative time and truncation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,47 +1,52 @@
|
||||
use super::*;
|
||||
use crate::cli::render;
|
||||
use crate::core::time::now_ms;
|
||||
|
||||
#[test]
|
||||
fn truncate_leaves_short_strings_alone() {
|
||||
assert_eq!(truncate_with_ellipsis("short", 10), "short");
|
||||
assert_eq!(render::truncate("short", 10), "short");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncate_adds_ellipsis_to_long_strings() {
|
||||
assert_eq!(
|
||||
truncate_with_ellipsis("this is a very long title", 15),
|
||||
render::truncate("this is a very long title", 15),
|
||||
"this is a ve..."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncate_handles_exact_length() {
|
||||
assert_eq!(truncate_with_ellipsis("exactly10!", 10), "exactly10!");
|
||||
assert_eq!(render::truncate("exactly10!", 10), "exactly10!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relative_time_formats_correctly() {
|
||||
let now = now_ms();
|
||||
|
||||
assert_eq!(format_relative_time(now - 30_000), "just now");
|
||||
assert_eq!(format_relative_time(now - 120_000), "2 min ago");
|
||||
assert_eq!(format_relative_time(now - 7_200_000), "2 hours ago");
|
||||
assert_eq!(format_relative_time(now - 172_800_000), "2 days ago");
|
||||
assert_eq!(render::format_relative_time(now - 30_000), "just now");
|
||||
assert_eq!(render::format_relative_time(now - 120_000), "2 min ago");
|
||||
assert_eq!(render::format_relative_time(now - 7_200_000), "2 hours ago");
|
||||
assert_eq!(
|
||||
render::format_relative_time(now - 172_800_000),
|
||||
"2 days ago"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_labels_empty() {
|
||||
assert_eq!(format_labels(&[], 2), "");
|
||||
assert_eq!(render::format_labels(&[], 2), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_labels_single() {
|
||||
assert_eq!(format_labels(&["bug".to_string()], 2), "[bug]");
|
||||
assert_eq!(render::format_labels(&["bug".to_string()], 2), "[bug]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_labels_multiple() {
|
||||
let labels = vec!["bug".to_string(), "urgent".to_string()];
|
||||
assert_eq!(format_labels(&labels, 2), "[bug, urgent]");
|
||||
assert_eq!(render::format_labels(&labels, 2), "[bug, urgent]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -52,7 +57,7 @@ fn format_labels_overflow() {
|
||||
"wip".to_string(),
|
||||
"blocked".to_string(),
|
||||
];
|
||||
assert_eq!(format_labels(&labels, 2), "[bug, urgent +2]");
|
||||
assert_eq!(render::format_labels(&labels, 2), "[bug, urgent +2]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user