From 65599ef1ee342f0aedc2524ccc931f7ce036e326 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 24 Dec 2024 12:59:11 -0500 Subject: [PATCH] Turn on non-interactive mode for structured output. --- cmd/state/internal/cmdtree/cmdtree.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/state/internal/cmdtree/cmdtree.go b/cmd/state/internal/cmdtree/cmdtree.go index 739a3cd727..54e0fe0208 100644 --- a/cmd/state/internal/cmdtree/cmdtree.go +++ b/cmd/state/internal/cmdtree/cmdtree.go @@ -295,7 +295,12 @@ func newStateCommand(globals *globalOptions, prime *primer.Values) *captain.Comm Shorthand: "o", Description: locale.T("flag_state_output_description"), Persist: true, - Value: &globals.Output, + OnUse: func() { + if prime.Output().Type().IsStructured() { + globals.NonInteractive = true + } + }, + Value: &globals.Output, }, { Name: "non-interactive", // Name and Shorthand should be kept in sync with cmd/state/output.go