feat: add --version flag to CLI (#94)
Print the current version when `agent-browser --version` is passed. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
6abee37641
commit
7bdfcf8541
+12
-6
@@ -21,7 +21,7 @@ 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;
|
||||||
use output::{print_command_help, print_help, print_response};
|
use output::{print_command_help, print_help, print_response, print_version};
|
||||||
|
|
||||||
fn run_session(args: &[String], session: &str, json_mode: bool) {
|
fn run_session(args: &[String], session: &str, json_mode: bool) {
|
||||||
let subcommand = args.get(1).map(|s| s.as_str());
|
let subcommand = args.get(1).map(|s| s.as_str());
|
||||||
@@ -99,11 +99,7 @@ fn main() {
|
|||||||
let clean = clean_args(&args);
|
let clean = clean_args(&args);
|
||||||
|
|
||||||
let has_help = args.iter().any(|a| a == "--help" || a == "-h");
|
let has_help = args.iter().any(|a| a == "--help" || a == "-h");
|
||||||
|
let has_version = args.iter().any(|a| a == "--version" || a == "-V");
|
||||||
if clean.is_empty() {
|
|
||||||
print_help();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if has_help {
|
if has_help {
|
||||||
if let Some(cmd) = clean.get(0) {
|
if let Some(cmd) = clean.get(0) {
|
||||||
@@ -115,6 +111,16 @@ fn main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if has_version {
|
||||||
|
print_version();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if clean.is_empty() {
|
||||||
|
print_help();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle install separately
|
// Handle install separately
|
||||||
if clean.get(0).map(|s| s.as_str()) == Some("install") {
|
if clean.get(0).map(|s| s.as_str()) == Some("install") {
|
||||||
let with_deps = args.iter().any(|a| a == "--with-deps" || a == "-d");
|
let with_deps = args.iter().any(|a| a == "--with-deps" || a == "-d");
|
||||||
|
|||||||
@@ -1197,6 +1197,7 @@ Options:
|
|||||||
--headed Show browser window (not headless)
|
--headed Show browser window (not headless)
|
||||||
--cdp <port> Connect via CDP (Chrome DevTools Protocol)
|
--cdp <port> Connect via CDP (Chrome DevTools Protocol)
|
||||||
--debug Debug output
|
--debug Debug output
|
||||||
|
--version, -V Show version
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
AGENT_BROWSER_SESSION Session name (default: "default")
|
AGENT_BROWSER_SESSION Session name (default: "default")
|
||||||
@@ -1215,3 +1216,7 @@ Examples:
|
|||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn print_version() {
|
||||||
|
println!("agent-browser {}", env!("CARGO_PKG_VERSION"));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user