added more verbose error output in the cli console

This commit is contained in:
pyro57000
2025-11-14 17:28:12 -06:00
parent 0841f38cb5
commit 8ff38acbf2
2 changed files with 14 additions and 6 deletions

View File

@@ -18,7 +18,11 @@ pub async fn rec_message(mut rx: Receiver<Message>) {
let rx_res = rx.try_recv(); let rx_res = rx.try_recv();
if rx_res.is_ok() { if rx_res.is_ok() {
let message = rx_res.unwrap(); let message = rx_res.unwrap();
println!("{}", message.content); if message.content.to_lowercase().contains("error") {
print_error(&message.content, None);
} else {
print_success(&message.content);
}
display = true; display = true;
} }
if display { if display {
@@ -38,6 +42,7 @@ pub async fn cli(
print_success("started the CLI!"); print_success("started the CLI!");
let mut commands = commands::build_tools(); let mut commands = commands::build_tools();
loop { loop {
let mut valid_command = false;
let settings = load_settings(&config_path, false); let settings = load_settings(&config_path, false);
projects = load_projects(&config_path, false); projects = load_projects(&config_path, false);
if tool_tx.is_closed() { if tool_tx.is_closed() {
@@ -61,9 +66,9 @@ pub async fn cli(
destination: Destination::Control, destination: Destination::Control,
content: String::from("exit"), content: String::from("exit"),
}; };
valid_command = true;
main_tx.send(message).await.unwrap(); main_tx.send(message).await.unwrap();
} }
let mut valid_command = false;
for toolcommand in &mut commands { for toolcommand in &mut commands {
let mut ready = true; let mut ready = true;
if toolcommand.name == command_name { if toolcommand.name == command_name {
@@ -75,9 +80,14 @@ pub async fn cli(
new_arg.name = req_arg; new_arg.name = req_arg;
args_vec.push(new_arg); args_vec.push(new_arg);
} }
println!("Required args:");
if args.len() < toolcommand.user_args.len() { if args.len() < toolcommand.user_args.len() {
ready = false; ready = false;
print_error("not enough arguments provided!", None);
let mut command_usage = format!("{}", toolcommand.name.clone());
for arg in toolcommand.user_args.clone() {
command_usage.push_str(&format!(" {}", &arg));
}
print_error("usage:", Some(command_usage));
} }
if ready { if ready {
let mut position_count = 0; let mut position_count = 0;
@@ -121,7 +131,6 @@ pub async fn cli(
} }
toolcommand.args = Some(args_vec); toolcommand.args = Some(args_vec);
} }
println!("args parsed!");
} }
let mut message = Message { let mut message = Message {
source: Destination::Console, source: Destination::Console,
@@ -140,7 +149,7 @@ pub async fn cli(
let message = Message { let message = Message {
source: Destination::Console, source: Destination::Console,
destination: Destination::Console, destination: Destination::Console,
content: String::from("command not found!"), content: String::from("error: command not found!"),
}; };
tool_tx.send(message).await.unwrap(); tool_tx.send(message).await.unwrap();
} }

View File

@@ -73,7 +73,6 @@ impl Table {
output.push_str("|\n"); output.push_str("|\n");
spacer.push_str("|\n"); spacer.push_str("|\n");
output.push_str(&spacer); output.push_str(&spacer);
output.push_str(&spacer);
for data_line in self.data.clone() { for data_line in self.data.clone() {
let line_vec: Vec<&str> = data_line.split("|").collect(); let line_vec: Vec<&str> = data_line.split("|").collect();
for id in 0..self.columns.len() { for id in 0..self.columns.len() {