From 2cfcb88993ba9796704125200c2f955437405983 Mon Sep 17 00:00:00 2001 From: Amariah Kamau <110414493+AmariahAK@users.noreply.github.com> Date: Thu, 6 Aug 2026 10:02:47 +0300 Subject: [PATCH] fix(environment): prioritize CLI flags over auto-detected stdin in get_edit_config Explicit --service-config and --service-variable flags now take priority over the stdin auto-detection path, so non-TTY environments (scripts, CI) that pass flags plus empty/redirected stdin no longer silently discard them. Also print 'No changes to apply' to stderr in non-TTY non-JSON mode so scripted callers can detect the no-op instead of getting silence. Fixes #1044 Co-authored-by: atlarix-agent --- src/commands/environment/edit.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands/environment/edit.rs b/src/commands/environment/edit.rs index b28e03899..8b6d216a9 100644 --- a/src/commands/environment/edit.rs +++ b/src/commands/environment/edit.rs @@ -69,6 +69,8 @@ pub async fn edit_environment(args: Args) -> Result<()> { ); } else if is_interactive { println!("{}", "No changes to apply".yellow()); + } else { + eprintln!("{}", "No changes to apply".yellow()); } return Ok(()); } @@ -215,16 +217,17 @@ async fn get_edit_config( let all_configs = args.config.get_all_service_configs(); let has_cli_flags = !all_configs.is_empty(); - // Priority 1: Piped stdin JSON (auto-detected) - if !stdin_is_terminal { - return read_config_from_stdin(environment_instances); - } - - // Priority 2: CLI flags (--service-config, --service-variable) + // Priority 1: CLI flags (--service-config, --service-variable) + // Explicit flags always take precedence over stdin auto-detection. if has_cli_flags { return parse_non_interactive_configs(&all_configs, environment_instances); } + // Priority 2: Piped stdin JSON (auto-detected) + if !stdin_is_terminal { + return read_config_from_stdin(environment_instances); + } + // Priority 3: Interactive prompts (terminal only) if std::io::stdout().is_terminal() { return parse_interactive_configs(