forked from TrueCloudLab/restic
ui: don't shorten non-interactive progress output
This commit is contained in:
parent
684600cf42
commit
023eea6463
1 changed files with 13 additions and 6 deletions
|
@ -314,17 +314,24 @@ func (t *Terminal) SetStatus(lines []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
width, _, err := terminal.GetSize(int(t.fd))
|
// only truncate interactive status output
|
||||||
if err != nil || width <= 0 {
|
var width int
|
||||||
// use 80 columns by default
|
if t.canUpdateStatus {
|
||||||
width = 80
|
var err error
|
||||||
|
width, _, err = terminal.GetSize(int(t.fd))
|
||||||
|
if err != nil || width <= 0 {
|
||||||
|
// use 80 columns by default
|
||||||
|
width = 80
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that all lines have a line break and are not too long
|
// make sure that all lines have a line break and are not too long
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
line = strings.TrimRight(line, "\n")
|
line = strings.TrimRight(line, "\n")
|
||||||
line = truncate(line, width-2) + "\n"
|
if width > 0 {
|
||||||
lines[i] = line
|
line = truncate(line, width-2)
|
||||||
|
}
|
||||||
|
lines[i] = line + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the last line does not have a line break
|
// make sure the last line does not have a line break
|
||||||
|
|
Loading…
Reference in a new issue