feat(snapshot): disable progress by default if no tty (#5066)

When running without a tty, disable progress by default. The progress
includes binary characters such as a spinner that do not display
properly without a tty.
This commit is contained in:
Preston Hunt
2026-02-06 19:45:26 -08:00
committed by GitHub
parent 6399642e46
commit 71e35d773f

View File

@@ -2,6 +2,7 @@
import (
"fmt"
"os"
"strconv"
"strings"
"sync"
@@ -10,6 +11,7 @@
"github.com/alecthomas/kingpin/v2"
"github.com/fatih/color"
"golang.org/x/term"
"github.com/kopia/kopia/internal/timetrack"
"github.com/kopia/kopia/internal/units"
@@ -29,7 +31,12 @@ type progressFlags struct {
}
func (p *progressFlags) setup(svc appServices, app *kingpin.Application) {
app.Flag("progress", "Enable progress output").Default("true").BoolVar(&p.enableProgress)
progressDefault := "true"
if !term.IsTerminal(int(os.Stdout.Fd())) {
progressDefault = "false"
}
app.Flag("progress", "Enable progress output").Default(progressDefault).BoolVar(&p.enableProgress)
app.Flag("progress-estimation-type", "Set type of estimation of the data to be snapshotted").Hidden().Default(upload.EstimationTypeClassic).
EnumVar(&p.progressEstimationType, upload.EstimationTypeClassic, upload.EstimationTypeRough, upload.EstimationTypeAdaptive)
app.Flag("progress-update-interval", "How often to update progress information").Hidden().Default("300ms").DurationVar(&p.progressUpdateInterval)