println

Function println 

Source
pub fn println(s: String) -> Cmd
Expand description

Creates a command that prints a line to the terminal.

This command sends a PrintMsg to the program, which will print the provided string to the terminal. This is useful for debugging or outputting information that should appear outside the normal UI.

§Arguments

  • s - The string to print

§Examples

use bubbletea_rs::{command, Model, Msg};

struct MyModel {
    debug_mode: bool,
}

impl Model for MyModel {
    fn init() -> (Self, Option<command::Cmd>) {
        (Self { debug_mode: true }, None)
    }

    fn update(&mut self, msg: Msg) -> Option<command::Cmd> {
        if self.debug_mode {
            // Note: In practice, msg doesn't implement Debug by default
            // This is just for demonstration
            return Some(command::println(
                "Received a message".to_string()
            ));
        }
        None
    }
     
    fn view(&self) -> String {
        "Debug mode active".to_string()
    }
}