Add automatic config file detection for dashboard TUI
- Dashboard now automatically looks for /etc/cm-dashboard/dashboard.toml - No need to specify --config flag when using standard NixOS deployment - Fallback to manual config path if default not found - Update help text to reflect optional config parameter - Simplifies dashboard usage - just run 'cm-dashboard' without arguments
This commit is contained in:
parent
3d2b37b26c
commit
a6c2983f65
@ -28,13 +28,23 @@ impl Dashboard {
|
||||
pub async fn new(config_path: Option<String>, headless: bool) -> Result<Self> {
|
||||
info!("Initializing dashboard");
|
||||
|
||||
// Load configuration - config file is required
|
||||
// Load configuration - try default path if not specified
|
||||
let config = match config_path {
|
||||
Some(path) => DashboardConfig::load_from_file(&path)?,
|
||||
None => {
|
||||
error!("Configuration file is required. Use --config to specify path.");
|
||||
error!("Dashboard configuration must be provided - no hardcoded defaults allowed.");
|
||||
return Err(anyhow::anyhow!("Missing required configuration file"));
|
||||
// Try default NixOS config path
|
||||
let default_path = "/etc/cm-dashboard/dashboard.toml";
|
||||
match DashboardConfig::load_from_file(default_path) {
|
||||
Ok(config) => {
|
||||
info!("Using default config file: {}", default_path);
|
||||
config
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Configuration file is required. Use --config to specify path or ensure {} exists.", default_path);
|
||||
error!("Failed to load default config: {}", e);
|
||||
return Err(anyhow::anyhow!("Missing required configuration file"));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ struct Cli {
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
verbose: u8,
|
||||
|
||||
/// Configuration file path (required)
|
||||
/// Configuration file path (defaults to /etc/cm-dashboard/dashboard.toml)
|
||||
#[arg(short, long)]
|
||||
config: Option<String>,
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user