looprs_core/adapters/
terminal_output.rs1use crate::ports::UserOutput;
9
10pub struct TerminalOutput;
12
13impl UserOutput for TerminalOutput {
14 fn info(&self, msg: &str) {
15 println!("{msg}");
16 }
17
18 fn warn(&self, msg: &str) {
19 eprintln!("warning: {msg}");
20 }
21
22 fn error(&self, msg: &str) {
23 eprintln!("error: {msg}");
24 }
25
26 fn assistant_text(&self, text: &str) {
27 println!("{text}");
28 }
29
30 fn tool_call(&self, tool_name: &str, input_preview: &str) {
31 println!("tool: {tool_name}({input_preview})");
32 }
33
34 fn tool_ok(&self) {
35 println!(" ok");
36 }
37
38 fn tool_err(&self, err_msg: &str) {
39 println!(" error: {err_msg}");
40 }
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn conformance() {
49 crate::ports::test_contracts::assert_user_output_contract(&TerminalOutput);
50 }
51}