Print progress at once off a terminal, keep warnings out of redraws (closes #13)
check / check (push) Successful in 1m24s
check / check (push) Successful in 1m24s
When stderr is not a terminal, each phase prints its zero-state line as it starts instead of after its first item. stderrIsTTY uses term.IsTerminal from golang.org/x/term, now a direct dependency, so /dev/null is no longer taken for a terminal. A spinner keeps the library's background redraw, so its count and elapsed time stay current while a phase waits for its next item. A warning printed during a spinner phase goes through the bar (progressbar.Bprintln), which prints it before its next redraw instead of racing it. Bars with a total have no background redraw and still print warnings directly. Model: opus-5-5
This commit is contained in:
@@ -113,7 +113,8 @@ Goals, in order:
|
||||
`sfdupes`.
|
||||
- Dependencies: standard library, `github.com/spf13/cobra` for the
|
||||
CLI, **one progress-bar library**
|
||||
(`github.com/schollz/progressbar/v3`), **one SQLite driver**
|
||||
(`github.com/schollz/progressbar/v3`), `golang.org/x/term` to tell
|
||||
whether stderr is a terminal, **one SQLite driver**
|
||||
(`modernc.org/sqlite`, pure Go, so builds keep cgo disabled), and
|
||||
`golang.org/x/sys` for `flock(2)` (the scan lock, see "Database").
|
||||
`github.com/spf13/viper` is permitted if configuration-file support
|
||||
@@ -572,10 +573,16 @@ hash: [12345/98765] 12% |████ | 92 files/s elapsed 2:32 eta 17:54
|
||||
|
||||
Additional requirements:
|
||||
|
||||
- When stderr is not a TTY, do not emit ANSI redraws: print a plain
|
||||
one-line progress update no more often than every 5 seconds instead.
|
||||
- When stderr is not a terminal (a pipe, a file, `/dev/null`), do not
|
||||
emit ANSI redraws: print a plain one-line progress update the moment
|
||||
each phase starts, then no more often than every 5 seconds.
|
||||
- Progress updates are driven from the main goroutine and must be
|
||||
non-blocking with respect to the worker pool.
|
||||
non-blocking with respect to the worker pool. On a terminal the
|
||||
spinner-style displays also redraw on their own several times a
|
||||
second, so their count and elapsed time stay current while a phase
|
||||
waits for its next item.
|
||||
- A warning printed during a phase always lands on a line of its own,
|
||||
never inside the progress display.
|
||||
- `report` and `trees` modes need no progress display, only their
|
||||
stderr summaries.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user