Skip to main content

systemprompt_logging/services/cli/
startup.rs

1use std::io::Write;
2
3use crate::services::cli::theme::BrandColors;
4
5fn stdout_writeln(args: std::fmt::Arguments<'_>) {
6    let mut out = std::io::stdout();
7    writeln!(out, "{args}").ok();
8}
9
10pub fn render_startup_banner(subtitle: Option<&str>) {
11    stdout_writeln(format_args!(""));
12    stdout_writeln(format_args!(
13        "{}{}{}{}{}",
14        BrandColors::primary_bold("</"),
15        BrandColors::white_bold("SYSTEMPROMPT"),
16        BrandColors::primary_bold("."),
17        BrandColors::white("io"),
18        BrandColors::primary_bold(">")
19    ));
20    if let Some(text) = subtitle {
21        stdout_writeln(format_args!("{}", BrandColors::dim(text)));
22    }
23    stdout_writeln(format_args!(""));
24}
25
26pub fn render_phase_header(name: &str) {
27    stdout_writeln(format_args!(
28        "\n{} {}",
29        BrandColors::primary("\u{25b8}"),
30        BrandColors::white_bold(name)
31    ));
32}
33
34pub fn render_phase_item(icon: &str, message: &str, detail: Option<&str>) {
35    match detail {
36        Some(d) => stdout_writeln(format_args!(
37            "  {} {} {}",
38            icon,
39            message,
40            BrandColors::dim(format!("({})", d))
41        )),
42        None => stdout_writeln(format_args!("  {} {}", icon, message)),
43    }
44}
45
46pub fn render_phase_success(message: &str, detail: Option<&str>) {
47    render_phase_item(
48        &format!("{}", BrandColors::running("\u{2713}")),
49        message,
50        detail,
51    );
52}
53
54pub fn render_phase_info(message: &str, detail: Option<&str>) {
55    render_phase_item(
56        &format!("{}", BrandColors::highlight("\u{2139}")),
57        message,
58        detail,
59    );
60}
61
62pub fn render_phase_warning(message: &str, detail: Option<&str>) {
63    render_phase_item(
64        &format!("{}", BrandColors::starting("\u{26a0}")),
65        message,
66        detail,
67    );
68}