diff options
author | Alexander Neumann <alexander@bumpern.de> | 2016-02-10 17:28:48 +0100 |
---|---|---|
committer | Alexander Neumann <alexander@bumpern.de> | 2016-02-10 17:28:48 +0100 |
commit | 4ec5050cbb9c42ad4979cf3ad830c7cf8826518c (patch) | |
tree | 42875954c42e050e36899189d2ab0c02b67bda79 /cmd | |
parent | eccbcb73a182b10cbeda2b98bc7e37d04d5cfe75 (diff) |
backup: Hide status output for narrow terminals
closes #428
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/restic/cmd_backup.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 63a652cbf..4524001c2 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -153,9 +153,13 @@ func (cmd CmdBackup) newArchiveProgress(todo restic.Stat) *restic.Progress { w, _, err := terminal.GetSize(int(os.Stdout.Fd())) if err == nil { - if len(status1)+len(status2) > w { - max := w - len(status2) - 4 - status1 = status1[:max] + "... " + maxlen := w - len(status2) + + if maxlen < 4 { + status1 = "" + } else if len(status1) > maxlen { + status1 = status1[:maxlen-4] + status1 += "... " } } |