From f7c9ac6241531c556544b5b398b474d05b67df9f Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:22:16 +0200 Subject: [PATCH] fix: `quiet` option sometimes only working as a flag (#846) In some places, the old `Flags().GetBool()` was used instead of actually using the option. That causes the `quiet` option to be ignored in these places if it is set via the config file or environment variables. --- internal/cmd/base/describe.go | 6 +++++- internal/state/actions.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/cmd/base/describe.go b/internal/cmd/base/describe.go index c3c6c733..c916175b 100644 --- a/internal/cmd/base/describe.go +++ b/internal/cmd/base/describe.go @@ -12,6 +12,7 @@ import ( "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/hcapi2" "github.com/hetznercloud/cli/internal/state" + "github.com/hetznercloud/cli/internal/state/config" ) // DescribeCmd allows defining commands for describing a resource. @@ -54,7 +55,10 @@ func (dc *DescribeCmd) CobraCommand(s state.State) *cobra.Command { func (dc *DescribeCmd) Run(s state.State, cmd *cobra.Command, args []string) error { outputFlags := output.FlagsForCommand(cmd) - quiet, _ := cmd.Flags().GetBool("quiet") + quiet, err := config.OptionQuiet.Get(s.Config()) + if err != nil { + return err + } isSchema := outputFlags.IsSet("json") || outputFlags.IsSet("yaml") if isSchema && !quiet { diff --git a/internal/state/actions.go b/internal/state/actions.go index 2bdb3c5a..323106e5 100644 --- a/internal/state/actions.go +++ b/internal/state/actions.go @@ -8,12 +8,17 @@ import ( "github.com/spf13/cobra" "github.com/hetznercloud/cli/internal/hcapi2" + "github.com/hetznercloud/cli/internal/state/config" "github.com/hetznercloud/cli/internal/ui" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func (c *state) WaitForActions(cmd *cobra.Command, ctx context.Context, actions ...*hcloud.Action) error { - if quiet, _ := cmd.Flags().GetBool("quiet"); quiet { + quiet, err := config.OptionQuiet.Get(c.Config()) + if err != nil { + return err + } + if quiet { return c.Client().Action().WaitFor(ctx, actions...) }