1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-25 01:06:39 +00:00

Merge pull request #1034 from restic/fix-1030

prune: Fix status string for narrow terminals
This commit is contained in:
Alexander Neumann 2017-06-15 20:22:33 +02:00
commit e3c979a7a4

View file

@ -28,6 +28,18 @@ func init() {
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.
func newProgressMax(show bool, max uint64, description string) *restic.Progress {
if !show {
@ -43,10 +55,7 @@ func newProgressMax(show bool, max uint64, description string) *restic.Progress
s.Blobs, max, description)
if w := stdoutTerminalWidth(); w > 0 {
if len(status) > w {
max := w - len(status) - 4
status = status[:max] + "... "
}
status = shortenStatus(w, status)
}
PrintProgress("%s", status)