Skip to main content

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        "─"
30            .repeat(inner_width.saturating_sub(header.len()))
31            .bright_cyan()
32    );
33
34    // Description
35    let desc_lines = textwrap::wrap(description, inner_width - 2);
36    for line in &desc_lines {
37        println!("{}  {}", "│".dimmed(), line.white());
38    }
39
40    // Bottom border
41    println!("{}{}", "└".dimmed(), "─".repeat(box_width - 1).dimmed());
42    println!();
43}
44
45/// Format a status indicator (checkmark or X)
46pub fn status_indicator(connected: bool) -> String {
47    if connected {
48        "✓".green().to_string()
49    } else {
50        "✗".red().to_string()
51    }
52}
53
54/// Format a count badge
55pub fn count_badge(count: usize, label: &str) -> String {
56    if count > 0 {
57        format!("{} {}", count.to_string().cyan(), label.dimmed())
58    } else {
59        format!("{} {}", "0".dimmed(), label.dimmed())
60    }
61}