(t *task)
| 546 | } |
| 547 | |
| 548 | func (w *ttyWriter) prepareLineData(t *task) lineData { |
| 549 | endTime := time.Now() |
| 550 | if t.status != api.Working { |
| 551 | endTime = t.startTime |
| 552 | if (t.endTime != time.Time{}) { |
| 553 | endTime = t.endTime |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | prefix := "" |
| 558 | if w.dryRun { |
| 559 | prefix = PrefixColor(DRYRUN_PREFIX) |
| 560 | } |
| 561 | |
| 562 | elapsed := endTime.Sub(t.startTime).Seconds() |
| 563 | |
| 564 | var ( |
| 565 | hideDetails bool |
| 566 | total int64 |
| 567 | current int64 |
| 568 | completion []string |
| 569 | ) |
| 570 | |
| 571 | // only show the aggregated progress while the root operation is in-progress |
| 572 | if t.status == api.Working { |
| 573 | for child := range w.childrenTasks(t.ID) { |
| 574 | if child.status == api.Working && child.total == 0 { |
| 575 | hideDetails = true |
| 576 | } |
| 577 | total += child.total |
| 578 | current += child.current |
| 579 | r := len(percentChars) - 1 |
| 580 | p := min(child.percent, 100) |
| 581 | completion = append(completion, percentChars[r*p/100]) |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | if total == 0 { |
| 586 | hideDetails = true |
| 587 | } |
| 588 | |
| 589 | var progress string |
| 590 | var progressSizeBytes int |
| 591 | if len(completion) > 0 { |
| 592 | progress = " [" + SuccessColor(strings.Join(completion, "")) + "]" |
| 593 | if !hideDetails { |
| 594 | sizeInfo := fmt.Sprintf(" %7s / %-7s", units.HumanSize(float64(current)), units.HumanSize(float64(total))) |
| 595 | progress += sizeInfo |
| 596 | progressSizeBytes = len(sizeInfo) |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | return lineData{ |
| 601 | spinner: spinner(t), |
| 602 | prefix: prefix, |
| 603 | taskID: t.ID, |
| 604 | progress: progress, |
| 605 | progressSizeBytes: progressSizeBytes, |
no test coverage detected