mirror of
https://github.com/kopia/kopia.git
synced 2026-05-14 01:37:07 -04:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user