better ax/dx (#11)

This commit is contained in:
Chris Tate
2026-01-11 23:48:07 -06:00
committed by GitHub
parent 9f7d7d6447
commit 24881c7327
2 changed files with 703 additions and 194 deletions
+686 -186
View File
File diff suppressed because it is too large Load Diff
+17 -8
View File
@@ -8,7 +8,7 @@ use serde_json::json;
use std::env; use std::env;
use std::process::exit; use std::process::exit;
use commands::{gen_id, parse_command}; use commands::{gen_id, parse_command, ParseError};
use connection::{ensure_daemon, send_command}; use connection::{ensure_daemon, send_command};
use flags::{clean_args, parse_flags}; use flags::{clean_args, parse_flags};
use install::run_install; use install::run_install;
@@ -32,13 +32,22 @@ fn main() {
} }
let cmd = match parse_command(&clean, &flags) { let cmd = match parse_command(&clean, &flags) {
Some(c) => c, Ok(c) => c,
None => { Err(e) => {
eprintln!( if flags.json {
"\x1b[31mUnknown command:\x1b[0m {}", let error_type = match &e {
clean.get(0).unwrap_or(&String::new()) ParseError::UnknownCommand { .. } => "unknown_command",
); ParseError::UnknownSubcommand { .. } => "unknown_subcommand",
eprintln!("\x1b[2mRun: agent-browser --help\x1b[0m"); ParseError::MissingArguments { .. } => "missing_arguments",
};
println!(
r#"{{"success":false,"error":"{}","type":"{}"}}"#,
e.format().replace('\n', " "),
error_type
);
} else {
eprintln!("\x1b[31m{}\x1b[0m", e.format());
}
exit(1); exit(1);
} }
}; };