[fix](trx-server): include legacy home config path and coords in print-config
Fix server config discovery to include ~/.trx-server.toml and update example/print-config output to explicitly include general latitude and longitude fields. Also update config docs and add a test for the legacy search path. Co-authored-by: Codex <codex@openai.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
//! Supports loading configuration from TOML files with the following search order:
|
||||
//! 1. Path specified via `--config` CLI argument
|
||||
//! 2. `./trx-server.toml` (current directory)
|
||||
//! 3. `~/.config/trx-rs/server.toml` (XDG config)
|
||||
//! 4. `/etc/trx-rs/server.toml` (system-wide)
|
||||
//! 3. `~/.trx-server.toml` (legacy per-user path)
|
||||
//! 4. `~/.config/trx-rs/server.toml` (XDG config)
|
||||
//! 5. `/etc/trx-rs/server.toml` (system-wide)
|
||||
|
||||
use std::net::IpAddr;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -317,8 +318,8 @@ impl ServerConfig {
|
||||
general: GeneralConfig {
|
||||
callsign: Some("N0CALL".to_string()),
|
||||
log_level: Some("info".to_string()),
|
||||
latitude: None,
|
||||
longitude: None,
|
||||
latitude: Some(52.2297),
|
||||
longitude: Some(21.0122),
|
||||
},
|
||||
rig: RigConfig {
|
||||
model: Some("ft817".to_string()),
|
||||
@@ -438,6 +439,9 @@ impl ConfigFile for ServerConfig {
|
||||
fn default_search_paths() -> Vec<PathBuf> {
|
||||
let mut paths = Vec::new();
|
||||
paths.push(PathBuf::from("trx-server.toml"));
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
paths.push(home_dir.join(".trx-server.toml"));
|
||||
}
|
||||
if let Some(config_dir) = dirs::config_dir() {
|
||||
paths.push(config_dir.join("trx-rs").join("server.toml"));
|
||||
}
|
||||
@@ -555,4 +559,12 @@ tokens = ["secret123"]
|
||||
config.audio.frame_duration_ms = 7;
|
||||
assert!(config.validate().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_search_paths_include_legacy_home_file() {
|
||||
let paths = ServerConfig::default_search_paths();
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
assert!(paths.contains(&home_dir.join(".trx-server.toml")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user