From 1999255c193ada19fa4b03909bc88ca38daf8a5f Mon Sep 17 00:00:00 2001 From: Kailan Blanks Date: Mon, 5 Aug 2024 14:34:57 +0100 Subject: [PATCH] Enable quiet mode when `--json` flag is supplied --- pkg/app/run.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/app/run.go b/pkg/app/run.go index 51d87d98c..24e413792 100644 --- a/pkg/app/run.go +++ b/pkg/app/run.go @@ -186,6 +186,11 @@ func Exec(data *global.Data) error { return err } + // Check for --json flag early and set quiet mode if found. + if slices.Contains(data.Args, "--json") { + data.Flags.Quiet = true + } + // We short-circuit the execution for specific cases: // // - argparser.ArgsIsHelpJSON() == true @@ -200,7 +205,7 @@ func Exec(data *global.Data) error { } metadataDisable, _ := strconv.ParseBool(data.Env.WasmMetadataDisable) - if !slices.Contains(data.Args, "--metadata-disable") && !metadataDisable && !data.Config.CLI.MetadataNoticeDisplayed && commandCollectsData(commandName) { + if !slices.Contains(data.Args, "--metadata-disable") && !metadataDisable && !data.Config.CLI.MetadataNoticeDisplayed && commandCollectsData(commandName) && !data.Flags.Quiet { text.Important(data.Output, "The Fastly CLI is configured to collect data related to Wasm builds (e.g. compilation times, resource usage, and other non-identifying data). To learn more about what data is being collected, why, and how to disable it: https://www.fastly.com/documentation/reference/cli") text.Break(data.Output) data.Config.CLI.MetadataNoticeDisplayed = true