use clap::Parser;
#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum TransportKind {
Stdio,
Http,
}
#[derive(Parser, Debug)]
#[command(name = "loctree-mcp")]
#[command(about = "Universal MCP server for loctree - works with any project")]
#[command(version = env!("LOCTREE_MCP_BUILD_VERSION"))]
pub(crate) struct Args {
#[arg(long, default_value = "info")]
pub(crate) log_level: String,
#[arg(long, value_enum, default_value_t = TransportKind::Stdio)]
pub(crate) transport: TransportKind,
#[arg(long, default_value = "127.0.0.1:5174")]
pub(crate) bind: String,
#[arg(long, alias = "project", value_name = "DIR")]
pub(crate) root: Option<String>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn root_flag_parses() {
let args = Args::parse_from(["loctree-mcp", "--root", "/tmp/x"]);
assert_eq!(args.root.as_deref(), Some("/tmp/x"));
}
#[test]
fn project_alias_parses_to_root() {
let args = Args::parse_from(["loctree-mcp", "--project", "/tmp/y"]);
assert_eq!(args.root.as_deref(), Some("/tmp/y"));
}
#[test]
fn no_root_is_none_universal_mode() {
let args = Args::parse_from(["loctree-mcp"]);
assert!(args.root.is_none());
}
}