get rid of fmt.Print* usages

This commit is contained in:
Michael Eischer
2025-09-14 15:29:39 +02:00
parent 3410808dcf
commit ca5b0c0249
7 changed files with 20 additions and 29 deletions

View File

@@ -1,8 +1,6 @@
package main
import (
"fmt"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/feature"
"github.com/restic/restic/internal/ui/table"
@@ -39,7 +37,7 @@ Exit status is 1 if there was any error.
return errors.Fatal("the feature command expects no arguments")
}
fmt.Printf("All Feature Flags:\n")
globalOptions.term.Print("All Feature Flags:\n")
flags := feature.Flag.List()
tab := table.New()

View File

@@ -24,7 +24,7 @@ Exit status is 1 if there was any error.
GroupID: cmdGroupAdvanced,
DisableAutoGenTag: true,
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf("All Extended Options:\n")
globalOptions.term.Print("All Extended Options:")
var maxLen int
for _, opt := range options.List() {
if l := len(opt.Namespace + "." + opt.Name); l > maxLen {
@@ -32,7 +32,7 @@ Exit status is 1 if there was any error.
}
}
for _, opt := range options.List() {
fmt.Printf(" %*s %s\n", -maxLen, opt.Namespace+"."+opt.Name, opt.Text)
globalOptions.term.Print(fmt.Sprintf(" %*s %s", -maxLen, opt.Namespace+"."+opt.Name, opt.Text))
}
},
}

View File

@@ -299,9 +299,7 @@ func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error {
}
// Info
if _, err := fmt.Fprintf(stdout, "snapshots"); err != nil {
return err
}
header := "snapshots"
var infoStrings []string
if key.Hostname != "" {
infoStrings = append(infoStrings, "host ["+key.Hostname+"]")
@@ -313,12 +311,10 @@ func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error {
infoStrings = append(infoStrings, "paths ["+strings.Join(key.Paths, ", ")+"]")
}
if infoStrings != nil {
if _, err := fmt.Fprintf(stdout, " for (%s)", strings.Join(infoStrings, ", ")); err != nil {
return err
}
header += " for (" + strings.Join(infoStrings, ", ") + ")"
}
_, err = fmt.Fprintf(stdout, ":\n")
header += ":\n"
_, err = stdout.Write([]byte(header))
return err
}