Wire the Progress interface into the CLI by adding a --quiet/-q global flag and a ProgressFromCmd helper that returns QuietProgress (stderr) when --quiet is set, or DefaultProgress (TTY-aware) otherwise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17 lines
353 B
Go
17 lines
353 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/Snider/Borg/pkg/ui"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// ProgressFromCmd returns a Progress based on --quiet flag and TTY detection.
|
|
func ProgressFromCmd(cmd *cobra.Command) ui.Progress {
|
|
quiet, _ := cmd.Flags().GetBool("quiet")
|
|
if quiet {
|
|
return ui.NewQuietProgress(os.Stderr)
|
|
}
|
|
return ui.DefaultProgress()
|
|
}
|