django-language-server/crates/djls/src/cli.rs

28 lines
690 B
Rust

use crate::args::Args;
use crate::commands::{Command, DjlsCommand};
use anyhow::Result;
use clap::Parser;
use std::process::ExitCode;
/// Main CLI structure that defines the command-line interface
#[derive(Parser)]
#[command(name = "djls")]
#[command(version, about)]
pub struct Cli {
#[command(subcommand)]
pub command: DjlsCommand,
#[command(flatten)]
pub args: Args,
}
/// Parse CLI arguments and execute the chosen command
pub async fn run(args: Vec<String>) -> Result<ExitCode> {
let cli = Cli::try_parse_from(args).unwrap_or_else(|e| {
e.exit();
});
match &cli.command {
DjlsCommand::Serve(cmd) => cmd.execute(&cli.args).await,
}
}