tofu-llm 0.7.2

A command-line tool for interacting with LLMs
Documentation
//! Tofu custom Dialoguer theme

use console::style;
use dialoguer::theme::Theme;

/// A simple theme that only styles input prompts
#[derive(Default, Clone, Copy)]
pub struct TofuTheme;

impl Theme for TofuTheme {
    fn format_input_prompt(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        default: Option<&str>,
    ) -> std::fmt::Result {
        if !prompt.is_empty() {
            write!(f, "{} ", style(prompt).bold().cyan())?;
        }

        match default {
            Some(default) if !prompt.is_empty() => {
                write!(f, "{} {}", style("[").dim(), style(default).italic().dim())?
            }
            Some(default) => write!(f, "{}", style(default).italic().dim())?,
            None => {}
        }

        write!(f, "{} ", style(">>").bold().cyan())
    }

    fn format_input_prompt_selection(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        sel: &str,
    ) -> std::fmt::Result {
        if !prompt.is_empty() {
            write!(f, "{} {}", style(prompt).bold().cyan(), style(sel).bold())
        } else {
            write!(f, "{} {}", style(">>").green(), sel)
        }
    }

    // Implement the required methods with default implementations
    fn format_confirm_prompt(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        default: Option<bool>,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_confirm_prompt(f, prompt, default)
    }

    fn format_confirm_prompt_selection(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        selection: Option<bool>,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_confirm_prompt_selection(f, prompt, selection)
    }

    fn format_password_prompt(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_password_prompt(f, prompt)
    }

    fn format_password_prompt_selection(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_password_prompt_selection(f, prompt)
    }

    fn format_select_prompt(&self, f: &mut dyn std::fmt::Write, prompt: &str) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_select_prompt(f, prompt)
    }

    fn format_select_prompt_selection(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        sel: &str,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_select_prompt_selection(f, prompt, sel)
    }

    fn format_multi_select_prompt(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_multi_select_prompt(f, prompt)
    }

    fn format_sort_prompt(&self, f: &mut dyn std::fmt::Write, prompt: &str) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_sort_prompt(f, prompt)
    }

    fn format_multi_select_prompt_selection(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        selections: &[&str],
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_multi_select_prompt_selection(f, prompt, selections)
    }

    fn format_sort_prompt_selection(
        &self,
        f: &mut dyn std::fmt::Write,
        prompt: &str,
        selections: &[&str],
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_sort_prompt_selection(f, prompt, selections)
    }

    fn format_select_prompt_item(
        &self,
        f: &mut dyn std::fmt::Write,
        text: &str,
        active: bool,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_select_prompt_item(f, text, active)
    }

    fn format_multi_select_prompt_item(
        &self,
        f: &mut dyn std::fmt::Write,
        text: &str,
        checked: bool,
        active: bool,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_multi_select_prompt_item(f, text, checked, active)
    }

    fn format_sort_prompt_item(
        &self,
        f: &mut dyn std::fmt::Write,
        text: &str,
        picked: bool,
        active: bool,
    ) -> std::fmt::Result {
        dialoguer::theme::SimpleTheme.format_sort_prompt_item(f, text, picked, active)
    }
}