From 21749a62eac0b03e05cbf04f39c688b3dfc282aa Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Wed, 14 Oct 2026 12:56:31 -0600 Subject: [PATCH] fix: config-path correctly displays the config file used even if --config-file is passed --- src/cli/mod.rs | 4 ++-- src/main.rs | 5 ++++- tests/unwritable_log_dir_cli_integration_tests.rs | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 1492b53d..8f74f403 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -51,8 +51,8 @@ pub enum Command { }, #[command(about = indoc!{" - Print the full path to the default configuration file. - This file can be changed to another location using the '--config-file' flag + Print the full path to the configuration file in use. + This is the default configuration file location unless overridden with the '--config-file' flag "})] ConfigPath, } diff --git a/src/main.rs b/src/main.rs index 0dd6140a..1917b46a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,10 @@ async fn main() -> Result<()> { let default_config_path = config_file_path.display().to_string(); if matches!(args.command, Some(Command::ConfigPath)) { - println!("{default_config_path}"); + match args.global.config_file { + Some(ref config_file) => println!("{}", config_file.display()), + None => println!("{default_config_path}"), + } return Ok(()); } diff --git a/tests/unwritable_log_dir_cli_integration_tests.rs b/tests/unwritable_log_dir_cli_integration_tests.rs index 5c9b4ce8..d42bd405 100644 --- a/tests/unwritable_log_dir_cli_integration_tests.rs +++ b/tests/unwritable_log_dir_cli_integration_tests.rs @@ -197,9 +197,11 @@ fn config_path_succeeds_without_loadable_tls_certificates() { let output = assertion.get_output(); let stderr = str::from_utf8(&output.stderr).unwrap(); - assert!( - !output.stdout.is_empty(), - "config-path produced no stdout despite exiting successfully" + let stdout = str::from_utf8(&output.stdout).unwrap(); + assert_eq!( + stdout.trim_end(), + env.base.join("config.yml").display().to_string(), + "config-path did not print the config file passed via --config-file" ); assert!( !stderr.contains("builder error"),