mod dashboard;
mod ports;
mod preview;
mod run;
mod sync;
mod theme;
mod update;
mod vsix;
mod widgets;
mod worktree;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "vkit", version, about = "Fast Rust CLI companion for vkit")]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand)]
enum Command {
Port,
Run,
Vsix,
Sync,
Preview,
Update,
#[command(visible_alias = "wt")]
Worktree(worktree::WtCli),
}
fn main() {
let cli = Cli::parse();
let needs_theme = match &cli.command {
Some(Command::Update) => false,
Some(Command::Worktree(wt)) => worktree::needs_tui(wt),
Some(_) | None => true,
};
if needs_theme {
let is_light = matches!(
termbg::theme(std::time::Duration::from_millis(100)),
Ok(termbg::Theme::Light)
);
theme::init(is_light);
}
let result = match cli.command {
Some(Command::Port) => ports::run(),
Some(Command::Run) => run::run(),
Some(Command::Vsix) => vsix::run(),
Some(Command::Sync) => sync::run(),
Some(Command::Preview) => preview::run(),
Some(Command::Update) => update::run(),
Some(Command::Worktree(wt)) => worktree::run_cli(wt),
None => dashboard::run(),
};
if let Err(err) = result {
eprintln!("错误:{err:#}");
std::process::exit(1);
}
}