vkit 0.1.4

Fast Rust dev CLI: manage git worktrees, Node ports, run scripts, install & sync VS Code / Cursor extensions.
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 {
    /// 管理 Node 端口:列出监听端口并一键关闭(仅 macOS)
    Port,
    /// 运行 scripts:扫描当前目录及子包的 package.json,多选批量运行
    Run,
    /// 安装插件:从 Marketplace 下载 VSIX 并装到 Cursor / VS Code
    Vsix,
    /// 同步插件:把 VS Code 已装扩展批量同步到 Cursor
    Sync,
    /// 主题预览:一屏查看所有主题色与组件样式
    Preview,
    /// 更新自身:从 GitHub Releases 下载最新版本并原地替换
    Update,
    /// 管理 git worktree:TUI / switch / shell-init(别名 wt)
    #[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);
    }
}