use clap::{Parser, ValueEnum};
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum Transport {
Stdio,
Http,
}
#[derive(Debug, Clone, Parser)]
#[command(name = "gdrive-mcp-server", about = "Google Drive MCP Server")]
pub struct AppConfig {
#[arg(long, env = "GDRIVE_MCP_TRANSPORT", default_value = "stdio")]
pub transport: Transport,
#[arg(long, env = "GDRIVE_MCP_HTTP_ADDR", default_value = "127.0.0.1:3000")]
pub http_addr: String,
#[arg(long, env = "GDRIVE_MCP_CREDENTIALS", default_value = "client_secret.json")]
pub credentials_file: String,
#[arg(long, env = "GDRIVE_MCP_TOKEN_CACHE", default_value = "~/.gdrive-mcp-token.json")]
pub token_cache_path: String,
#[arg(long, env = "GDRIVE_MCP_LOG_LEVEL", default_value = "info")]
pub log_level: String,
}
impl AppConfig {
pub fn resolved_token_cache_path(&self) -> String {
if self.token_cache_path.starts_with('~') {
if let Some(home) = dirs_home() {
return self.token_cache_path.replacen('~', &home, 1);
}
}
self.token_cache_path.clone()
}
}
fn dirs_home() -> Option<String> {
std::env::var("HOME")
.ok()
.or_else(|| std::env::var("USERPROFILE").ok())
}