Skip to content

Commit 0e88b9a

Browse files
committed
extend agent command lines
1 parent aaeb895 commit 0e88b9a

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

src/helpers/command_lines.rs

+43-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
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+
}
333

434
// get user request
535
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();
737

838
// print the questions in a specific color
939
stdout.execute(SetForegroundColor(Color::Blue)).unwrap();
@@ -15,4 +45,14 @@ pub fn get_user_response(question: &str) -> String {
1545
let mut user_response = String::new();
1646
stdin().read_line(&mut user_response).expect("Failed to read response");
1747
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+
}
1858
}

0 commit comments

Comments
 (0)