Skip to content

Commit

Permalink
move logic
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Jan 4, 2024
1 parent 6c84163 commit 32afd2f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ func NewRootCommand(s state.State) *cobra.Command {
)
cmd.PersistentFlags().Duration("poll-interval", 500*time.Millisecond, "Interval at which to poll information, for example action progress")
cmd.PersistentFlags().Bool("quiet", false, "Only print error messages")
cmd.SetOut(os.Stdout)

cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
out := os.Stdout
if quiet, _ := cmd.Flags().GetBool("quiet"); quiet {
f, err := os.Open(os.DevNull)
var err error
out, err = os.Open(os.DevNull)
if err != nil {
return err
}
cmd.SetOut(f)
}
cmd.SetOut(out)
return nil
}
return cmd
Expand Down

0 comments on commit 32afd2f

Please sign in to comment.