fix: Improved the first-time run behavior so that it outputs the default configuration file it tries to load to help users locate the file on first-runs

This commit is contained in:
2026-01-30 15:36:26 -07:00
parent c791b985f0
commit a2aa9507a9
5 changed files with 120 additions and 152 deletions
+15 -10
View File
@@ -2,7 +2,7 @@
#[macro_use]
extern crate assertables;
use anyhow::Result;
use anyhow::{Context, Result};
use clap::{
Args, CommandFactory, Parser, crate_authors, crate_description, crate_name, crate_version,
};
@@ -127,25 +127,30 @@ async fn main() -> Result<()> {
let running = Arc::new(AtomicBool::new(true));
let r = running.clone();
let args = Cli::parse();
let config_file_path = confy::get_configuration_file_path("managarr", "config")?;
let default_config_path = config_file_path.display().to_string();
if matches!(args.command, Some(Command::ConfigPath)) {
println!(
"{}",
confy::get_configuration_file_path("managarr", "config")?.display()
);
println!("{default_config_path}");
return Ok(());
}
let mut config = if let Some(ref config_file) = args.global.config_file {
load_config(config_file.to_str().expect("Invalid config file specified"))?
let (mut config, config_path) = if let Some(ref config_file) = args.global.config_file {
(
load_config(config_file.to_str().expect("Invalid config file specified"))?,
config_file.display().to_string(),
)
} else {
confy::load("managarr", "config")?
(
confy::load("managarr", "config")
.with_context(|| format!("Config file at '{default_config_path}' is invalid"))?,
default_config_path,
)
};
let theme_name = config.theme.clone();
let spinner_disabled = args.global.disable_spinner;
debug!("Managarr loaded using config: {config:?}");
config.validate();
config.validate(&config_path);
config.post_process_initialization();
let reqwest_client = build_network_client(&config);