Indent snapshot summary details; add Finished message; fix 'to process'
- New ui.Detail method for indented continuation lines under a preceding Complete (visually same as Progress: " 》" in white). - Snapshot summary lines (Files/Data/Storage/Upload/Duration) are now Detail lines indented under "Created snapshot X.". - Local index database prune complete result lines (incomplete snapshots, orphaned files/chunks/blobs) are also Detail lines under a clean Complete header. - "Files: ... to process" → "Files: ... processed" (they have been processed by the time we emit the summary). - "Data: ... (... to process)" → "Data: ... (... processed)". - ui.Writer now tracks warning and error counts emitted; Vaultik prints "Finished successfully." or "Finished (with N warnings)." as the final line of CreateSnapshot.
This commit is contained in:
@@ -46,9 +46,14 @@ const (
|
||||
const Marker = "》"
|
||||
|
||||
// Writer formats and emits user-facing messages with optional ANSI color.
|
||||
// It also counts warnings and errors emitted so the caller can summarize at
|
||||
// the end of an operation ("Finished successfully." vs "Finished with
|
||||
// warnings.").
|
||||
type Writer struct {
|
||||
out io.Writer
|
||||
color bool
|
||||
out io.Writer
|
||||
color bool
|
||||
warnings int
|
||||
errors int
|
||||
}
|
||||
|
||||
// New returns a Writer that emits to out. Color is enabled when out is a
|
||||
@@ -115,6 +120,7 @@ func (w *Writer) Notice(format string, args ...any) {
|
||||
|
||||
// Warning prints "⚠️ Warning: " in orange/yellow followed by the message.
|
||||
func (w *Writer) Warning(format string, args ...any) {
|
||||
w.warnings++
|
||||
prefix := "⚠️ " + w.paint(ansiYellow+ansiBold, "Warning: ")
|
||||
_, _ = fmt.Fprintln(w.out, prefix+fmt.Sprintf(format, args...))
|
||||
}
|
||||
@@ -123,10 +129,25 @@ func (w *Writer) Warning(format string, args ...any) {
|
||||
// same writer as everything else; callers that want stderr should
|
||||
// construct a separate Writer for it.
|
||||
func (w *Writer) Error(format string, args ...any) {
|
||||
w.errors++
|
||||
prefix := "🛑 " + w.paint(ansiRed+ansiBold, "ERROR: ")
|
||||
_, _ = fmt.Fprintln(w.out, prefix+fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
// Detail prints an indented continuation line under a preceding Complete
|
||||
// (or other top-level message). Marker " 》" (white) at column 2.
|
||||
// Distinct from Progress (semantically a "heartbeat") in usage but
|
||||
// visually identical.
|
||||
func (w *Writer) Detail(format string, args ...any) {
|
||||
w.emit(ansiWhite, " "+Marker, "", format, args)
|
||||
}
|
||||
|
||||
// WarningCount returns the number of Warning() calls this writer has emitted.
|
||||
func (w *Writer) WarningCount() int { return w.warnings }
|
||||
|
||||
// ErrorCount returns the number of Error() calls this writer has emitted.
|
||||
func (w *Writer) ErrorCount() int { return w.errors }
|
||||
|
||||
// Progress prints an indented heartbeat / per-item update, marker in white.
|
||||
func (w *Writer) Progress(format string, args ...any) {
|
||||
w.emit(ansiWhite, " "+Marker, "", format, args)
|
||||
|
||||
Reference in New Issue
Block a user