greppy/cli/
web.rs

1//! Web command implementation
2//!
3//! Launches the greppy web UI for visual codebase exploration.
4//!
5//! @module cli/web
6
7use clap::Args;
8use std::env;
9use std::path::PathBuf;
10
11use crate::core::error::Result;
12
13/// Arguments for the web command
14#[derive(Args, Debug)]
15#[command(after_help = "EXAMPLES:
16    greppy web                    Start web UI on localhost:3000
17    greppy web --port 8080        Use custom port
18    greppy web --open             Auto-open browser
19    greppy web -p ~/project       Specify project path")]
20pub struct WebArgs {
21    /// Project path (default: current directory)
22    #[arg(short, long)]
23    pub project: Option<PathBuf>,
24
25    /// Port to serve on (default: 3000)
26    #[arg(long, default_value = "3000")]
27    pub port: u16,
28
29    /// Auto-open browser
30    #[arg(long)]
31    pub open: bool,
32}
33
34/// Run the web command
35pub async fn run(args: WebArgs) -> Result<()> {
36    let project_path = args
37        .project
38        .unwrap_or_else(|| env::current_dir().expect("Failed to get current directory"));
39
40    crate::web::server::run(project_path, args.port, args.open).await
41}