forked from TrueCloudLab/restic
parent
aabe2a0a30
commit
9a8301fc74
1 changed files with 13 additions and 4 deletions
|
@ -28,6 +28,18 @@ func init() {
|
||||||
cmdRoot.AddCommand(cmdPrune)
|
cmdRoot.AddCommand(cmdPrune)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shortenStatus(maxLength int, s string) string {
|
||||||
|
if len(s) <= maxLength {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
if maxLength < 3 {
|
||||||
|
return s[:maxLength]
|
||||||
|
}
|
||||||
|
|
||||||
|
return s[:maxLength-3] + "..."
|
||||||
|
}
|
||||||
|
|
||||||
// newProgressMax returns a progress that counts blobs.
|
// newProgressMax returns a progress that counts blobs.
|
||||||
func newProgressMax(show bool, max uint64, description string) *restic.Progress {
|
func newProgressMax(show bool, max uint64, description string) *restic.Progress {
|
||||||
if !show {
|
if !show {
|
||||||
|
@ -43,10 +55,7 @@ func newProgressMax(show bool, max uint64, description string) *restic.Progress
|
||||||
s.Blobs, max, description)
|
s.Blobs, max, description)
|
||||||
|
|
||||||
if w := stdoutTerminalWidth(); w > 0 {
|
if w := stdoutTerminalWidth(); w > 0 {
|
||||||
if len(status) > w {
|
status = shortenStatus(w, status)
|
||||||
max := w - len(status) - 4
|
|
||||||
status = status[:max] + "... "
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintProgress("%s", status)
|
PrintProgress("%s", status)
|
||||||
|
|
Loading…
Reference in a new issue