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> {
|
pub async fn new(config_path: Option<String>, headless: bool) -> Result<Self> {
|
||||||
info!("Initializing dashboard");
|
info!("Initializing dashboard");
|
||||||
|
|
||||||
// Load configuration - config file is required
|
// Load configuration - try default path if not specified
|
||||||
let config = match config_path {
|
let config = match config_path {
|
||||||
Some(path) => DashboardConfig::load_from_file(&path)?,
|
Some(path) => DashboardConfig::load_from_file(&path)?,
|
||||||
None => {
|
None => {
|
||||||
error!("Configuration file is required. Use --config to specify path.");
|
// Try default NixOS config path
|
||||||
error!("Dashboard configuration must be provided - no hardcoded defaults allowed.");
|
let default_path = "/etc/cm-dashboard/dashboard.toml";
|
||||||
return Err(anyhow::anyhow!("Missing required configuration file"));
|
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)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
|
|
||||||
/// Configuration file path (required)
|
/// Configuration file path (defaults to /etc/cm-dashboard/dashboard.toml)
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
config: Option<String>,
|
config: Option<String>,
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user