config.rs

 1use clap::Parser;
 2use rmcp::serde_json;
 3use std::path::PathBuf;
 4
 5#[derive(Parser, Debug)]
 6#[command(version, about)]
 7pub struct CommandLineArgs {
 8    #[arg(short, long, value_name = "FILE")]
 9    pub config: PathBuf,
10}
11
12#[derive(serde::Deserialize, Debug)]
13pub struct Command {
14    pub command: String,
15    pub args: Vec<String>,
16}
17
18#[derive(serde::Deserialize, Debug)]
19pub struct Config {
20    pub lsp_server_command: Command,
21    pub project_root: PathBuf,
22}
23
24impl Config {
25    pub async fn load(path: &PathBuf) -> Result<Self, Box<dyn std::error::Error>> {
26        let config_content = tokio::fs::read_to_string(path).await?;
27        let config: Config = serde_json::from_str(&config_content)?;
28        Ok(config)
29    }
30}