Struct UI

Source
pub struct UI;
Expand description

User interface handler for terminal output

Provides static methods for printing formatted and colored messages to the terminal during the conversation flow.

§Color Scheme

  • Blue: Separators and Claude prompt
  • Yellow: Title and exit message
  • Green: System prompt info, model info, and user prompt

§Examples

use claude_dialog::ui::UI;

// Display welcome screen
UI::print_welcome("Custom system prompt loaded", None);

// Show user prompt (typically followed by user input)
UI::print_user_prompt();

Implementations§

Source§

impl UI

Source

pub fn print_welcome(system_prompt_info: &str, model: Option<&String>)

Print the welcome banner with system information

Displays a formatted welcome message including the system prompt status and optionally the model being used.

§Arguments
  • system_prompt_info - Description of the system prompt configuration
  • model - Optional model name to display
§Output Format
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Claude Dialog Shell
System Prompt: [system_prompt_info]
Model: [model] (if provided)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
Type 'exit' or 'quit' to end the conversation
§Examples
use claude_dialog::ui::UI;

// With model specified
UI::print_welcome("Using custom prompt from file", Some(&"claude-3-opus".to_string()));

// Without model
UI::print_welcome("Using default system prompt", None);
Source

pub fn print_user_prompt()

Print the user input prompt

Displays a colored prompt indicator for user input. This should be called before reading user input.

§Output

Prints “You> “ in green color without a newline.

§Examples
use claude_dialog::ui::UI;
use std::io::{self, Write};

UI::print_user_prompt();
io::stdout().flush().unwrap(); // Ensure prompt is displayed
// User types their input here
Source

pub fn print_claude_prompt()

Print the Claude response prompt

Displays a colored prompt indicator before Claude’s response. This should be called before executing the Claude command.

§Output

Prints “Claude>” in blue color with a newline.

§Examples
use claude_dialog::ui::UI;

UI::print_claude_prompt();
// Claude's response will follow
Source

pub fn print_exit_message()

Print the exit message

Displays a farewell message when the user exits the conversation.

§Output

Prints “Exiting conversation…” in yellow color.

§Examples
use claude_dialog::ui::UI;

// When user types "exit" or "quit"
UI::print_exit_message();

Auto Trait Implementations§

§

impl Freeze for UI

§

impl RefUnwindSafe for UI

§

impl Send for UI

§

impl Sync for UI

§

impl Unpin for UI

§

impl UnwindSafe for UI

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.