1
- use crossterm:: { style:: { Color , ResetColor , SetForegroundColor } , ExecutableCommand } ;
2
- use std:: io:: stdin;
1
+ use crossterm:: { style:: { Color , ResetColor , SetForegroundColor } , ExecutableCommand , QueueableCommand } ;
2
+ use std:: io:: { stdin, stdout} ;
3
+
4
+
5
+ #[ derive( PartialEq , Debug ) ]
6
+ pub enum PrintCommand {
7
+ AICall ,
8
+ UnitTest ,
9
+ Issue ,
10
+ }
11
+
12
+ impl PrintCommand {
13
+ pub fn print_agent_message ( & self , agent_position : & str , agent_statement : & str ) {
14
+ let mut stdout: std:: io:: Stdout = stdout ( ) ;
15
+
16
+ let statement_color: Color = match self {
17
+ PrintCommand :: AICall => Color :: Cyan ,
18
+ PrintCommand :: UnitTest => Color :: Magenta ,
19
+ PrintCommand :: Issue => Color :: Red ,
20
+ } ;
21
+
22
+ // Print the agent statement in a specific color
23
+ stdout. execute ( SetForegroundColor ( Color :: Green ) ) . unwrap ( ) ;
24
+ print ! ( "Agent: {}: " , agent_position) ;
25
+
26
+ //Make selected color
27
+ stdout. execute ( SetForegroundColor ( statement_color) ) . unwrap ( ) ;
28
+ println ! ( "{}" , agent_statement) ;
29
+
30
+ stdout. execute ( ResetColor ) . unwrap ( ) ;
31
+ }
32
+ }
3
33
4
34
// get user request
5
35
pub fn get_user_response ( question : & str ) -> String {
6
- let mut stdout: std:: io:: Stdout = std :: io :: stdout ( ) ;
36
+ let mut stdout: std:: io:: Stdout = stdout ( ) ;
7
37
8
38
// print the questions in a specific color
9
39
stdout. execute ( SetForegroundColor ( Color :: Blue ) ) . unwrap ( ) ;
@@ -15,4 +45,14 @@ pub fn get_user_response(question: &str) -> String {
15
45
let mut user_response = String :: new ( ) ;
16
46
stdin ( ) . read_line ( & mut user_response) . expect ( "Failed to read response" ) ;
17
47
return user_response. trim ( ) . to_string ( ) ;
48
+ }
49
+
50
+
51
+ #[ cfg( test) ]
52
+ mod tests {
53
+ use super :: * ;
54
+ #[ test]
55
+ fn test_print_agent_message ( ) {
56
+ PrintCommand :: AICall . print_agent_message ( "Managing Agent" , "Testing, Processing something" )
57
+ }
18
58
}
0 commit comments