Reformat progress lines and prune output
Progress lines now use the form: ..., <subject> elapsed: <dur>, <subject> ETA: <time> (est remain <dur>). ui.Time formats same-day times as HH:MM:SS and other-day times as YYYY-MM-DD HH:MM:SS, with no timezone suffix (local time is implied). The local-index-database prune complete line now shows remaining counts for each category: ... 1 incomplete snapshots removed (3 remain), 3783 orphaned files removed (42 remain), ...
This commit is contained in:
@@ -188,9 +188,17 @@ func (w *Writer) Duration(d time.Duration) string {
|
||||
return w.paint(ansiYellow, d.Round(time.Second).String())
|
||||
}
|
||||
|
||||
// Time colorizes an absolute time (RFC3339, second precision).
|
||||
// Time colorizes an absolute clock time. If t falls on today's local
|
||||
// calendar date the output is "HH:MM:SS"; otherwise it is
|
||||
// "YYYY-MM-DD HH:MM:SS". No timezone is included — values are
|
||||
// displayed in the process's local zone.
|
||||
func (w *Writer) Time(t time.Time) string {
|
||||
return w.paint(ansiYellow, t.Format(time.RFC3339))
|
||||
t = t.Local()
|
||||
now := time.Now()
|
||||
if t.Year() == now.Year() && t.YearDay() == now.YearDay() {
|
||||
return w.paint(ansiYellow, t.Format("15:04:05"))
|
||||
}
|
||||
return w.paint(ansiYellow, t.Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
|
||||
// Count colorizes an integer count with thousands separators.
|
||||
|
||||
@@ -72,6 +72,16 @@ func TestValueFormattersPlain(t *testing.T) {
|
||||
if got := w.Percent(12.34); got != "12.3%" {
|
||||
t.Errorf("Percent: got %q", got)
|
||||
}
|
||||
|
||||
// Time format: today → HH:MM:SS, other day → YYYY-MM-DD HH:MM:SS.
|
||||
today := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 14, 30, 45, 0, time.Local)
|
||||
if got := w.Time(today); got != "14:30:45" {
|
||||
t.Errorf("Time today: got %q, want 14:30:45", got)
|
||||
}
|
||||
other := time.Date(2030, 1, 2, 3, 4, 5, 0, time.Local)
|
||||
if got := w.Time(other); got != "2030-01-02 03:04:05" {
|
||||
t.Errorf("Time other day: got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValueFormattersColored(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user