syncable_cli/wizard/
render.rs

1//! Shared rendering utilities for wizard prompts
2
3use colored::Colorize;
4use inquire::ui::{Color, IndexPrefix, RenderConfig, StyleSheet, Styled};
5
6/// Get the standard render config for wizard prompts
7pub fn wizard_render_config() -> RenderConfig<'static> {
8    RenderConfig::default()
9        .with_highlighted_option_prefix(Styled::new("▸ ").with_fg(Color::LightCyan))
10        .with_option_index_prefix(IndexPrefix::Simple)
11        .with_selected_option(Some(StyleSheet::new().with_fg(Color::LightCyan)))
12        .with_scroll_up_prefix(Styled::new("▲ "))
13        .with_scroll_down_prefix(Styled::new("▼ "))
14}
15
16/// Display a wizard step header box
17pub fn display_step_header(step_number: u8, step_name: &str, description: &str) {
18    let term_width = term_size::dimensions().map(|(w, _)| w).unwrap_or(80);
19    let box_width = term_width.min(70);
20    let inner_width = box_width - 4;
21
22    println!();
23    // Top border with step indicator
24    let header = format!("─ Step {} · {} ", step_number, step_name);
25    println!(
26        "{}{}{}",
27        "┌".bright_cyan(),
28        header.bright_cyan(),
29        "─".repeat(inner_width.saturating_sub(header.len())).bright_cyan()
30    );
31
32    // Description
33    let desc_lines = textwrap::wrap(description, inner_width - 2);
34    for line in &desc_lines {
35        println!(
36            "{}  {}",
37            "│".dimmed(),
38            line.white()
39        );
40    }
41
42    // Bottom border
43    println!(
44        "{}{}",
45        "└".dimmed(),
46        "─".repeat(box_width - 1).dimmed()
47    );
48    println!();
49}
50
51/// Format a status indicator (checkmark or X)
52pub fn status_indicator(connected: bool) -> String {
53    if connected {
54        "✓".green().to_string()
55    } else {
56        "✗".red().to_string()
57    }
58}
59
60/// Format a count badge
61pub fn count_badge(count: usize, label: &str) -> String {
62    if count > 0 {
63        format!("{} {}", count.to_string().cyan(), label.dimmed())
64    } else {
65        format!("{} {}", "0".dimmed(), label.dimmed())
66    }
67}