Skip to content

Commit

Permalink
fix: quiet option sometimes only working as a flag (#846)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phm07 committed Aug 19, 2024
1 parent 7355571 commit f7c9ac6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/cmd/base/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion internal/state/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

Expand Down

0 comments on commit f7c9ac6

Please sign in to comment.