use anyhow::Result;
use browser_control::cli::list;
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "browser-control", version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand, Debug)]
enum Command {
ListInstalled {
#[arg(long)]
json: bool,
},
ListRunning {
#[arg(long)]
json: bool,
},
Start {
browser: Option<String>,
#[arg(long)]
headless: bool,
#[arg(long)]
profile: Option<std::path::PathBuf>,
#[arg(long)]
json: bool,
},
Mcp {
browser: Option<String>,
#[arg(long)]
playwright: bool,
},
}
fn init_tracing() {
let filter = tracing_subscriber::EnvFilter::try_from_env("BROWSER_CONTROL_LOG")
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));
tracing_subscriber::fmt()
.with_env_filter(filter)
.with_writer(std::io::stderr)
.init();
}
#[tokio::main]
async fn main() -> Result<()> {
init_tracing();
let cli = Cli::parse();
match cli.command {
Command::ListInstalled { json } => list::run_list_installed(json),
Command::ListRunning { json } => list::run_list_running(json),
Command::Start {
browser,
headless,
profile,
json,
} => browser_control::cli::start::run(browser, headless, profile, json).await,
Command::Mcp {
browser,
playwright,
} => browser_control::cli::mcp::run_cli(browser, playwright).await,
}
}