Documentation
¶
Index ¶
- Variables
- func CountPayload(count int) map[string]any
- func Detail(ctx context.Context, jsonData any, plainValues []any, fields []Field) error
- func ErrorPayload(err error) map[string]any
- func Fprintf(ctx context.Context, format string, args ...any) (int, error)
- func Fprintln(ctx context.Context, args ...any) (int, error)
- func IDPayload(id string) map[string]any
- func IsHuman(ctx context.Context) bool
- func IsJSON(ctx context.Context) bool
- func IsPlain(ctx context.Context) bool
- func JSON(ctx context.Context, v any) error
- func JSONErr(ctx context.Context, v any) error
- func PathPayload(path string) map[string]any
- func Plain(ctx context.Context, values ...any) error
- func PlainFromSlice(ctx context.Context, slice any, fields []string) error
- func PlainFromStruct(ctx context.Context, v any, fields []string) error
- func PlainRows(ctx context.Context, rows [][]any) error
- func Print(ctx context.Context, jsonData any, plainValues []any, humanFn func() error) error
- func PrintSlice(ctx context.Context, slice any, fields []string, headers []string) error
- func StatusPayload(status string, message string) map[string]any
- func SuccessPayload(message string) map[string]any
- func WithMode(ctx context.Context, mode Mode) context.Context
- func WithProgress(ctx context.Context, p *Progress) context.Context
- func WithSyncTimeline(ctx context.Context, tl *SyncTimeline) context.Context
- func WithWriter(ctx context.Context, w *Writer) context.Context
- func WriteDetail(w io.Writer, fields []Field) error
- func WriteJSON(w io.Writer, v any) error
- func WritePlain(w io.Writer, values ...any) error
- func WriteTable(ctx context.Context, slice any, fields []string, headers []string) error
- type CopyTimeline
- func (tl *CopyTimeline) Close()
- func (tl *CopyTimeline) ErrorFooter(msg string)
- func (tl *CopyTimeline) Footer()
- func (tl *CopyTimeline) Header(from, to string)
- func (tl *CopyTimeline) PreparePrompt()
- func (tl *CopyTimeline) StageDone(name, summary string)
- func (tl *CopyTimeline) StageItem(name, detail string, current, total int64)
- func (tl *CopyTimeline) StageSkip(name, reason string)
- func (tl *CopyTimeline) StageStart(name string)
- func (tl *CopyTimeline) StageWarning(stage, msg string)
- func (tl *CopyTimeline) SubStageDone(stage, sub, summary string)
- type Field
- type Mode
- type ParseError
- type Progress
- type SyncCategory
- type SyncTimeline
- func (tl *SyncTimeline) CategoryDone(index int)
- func (tl *SyncTimeline) Close()
- func (tl *SyncTimeline) DeleteFailed(displayPath, errorDetail string)
- func (tl *SyncTimeline) DeletesDone()
- func (tl *SyncTimeline) ErrorFooter()
- func (tl *SyncTimeline) FileDeleted()
- func (tl *SyncTimeline) FileFailed(displayPath, errorDetail string)
- func (tl *SyncTimeline) FileSkipped()
- func (tl *SyncTimeline) FileUploaded()
- func (tl *SyncTimeline) Footer()
- func (tl *SyncTimeline) Header()
- func (tl *SyncTimeline) NothingToDo()
- func (tl *SyncTimeline) PreparePrompt()
- func (tl *SyncTimeline) RenderPlan(categories []SyncCategory, deleteCount int)
- func (tl *SyncTimeline) SetActiveDelete(displayPath string)
- func (tl *SyncTimeline) SetActiveFile(displayPath string)
- func (tl *SyncTimeline) SetCategories(categories []SyncCategory)
- func (tl *SyncTimeline) StartCategory(index int)
- func (tl *SyncTimeline) StartDeletes(total int)
- type Table
- type Task
- func (t *Task) Add(n int64)
- func (t *Task) Current() int64
- func (t *Task) Done(status string)
- func (t *Task) Fail(err error)
- func (t *Task) ResetProgress()
- func (t *Task) SetLabel(label string)
- func (t *Task) SetTotal(total int64)
- func (t *Task) WrapReadCloser(reader io.ReadCloser) io.ReadCloser
- func (t *Task) WrapReader(reader io.Reader) io.Reader
- func (t *Task) WrapWriter(writer io.Writer) io.Writer
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrOutputConflict = errors.New("cannot combine --json and --plain")
Functions ¶
func CountPayload ¶
CountPayload creates a count result object.
func Detail ¶ added in v0.1.5
Detail writes a single resource across all three output modes. JSON mode writes jsonData, Plain mode writes plainValues as TSV, and Human mode renders fields as aligned key-value pairs.
func ErrorPayload ¶
ErrorPayload creates an error status object.
func PathPayload ¶
PathPayload creates a path result object.
func PlainFromSlice ¶
PlainFromSlice writes each struct in a slice as a TSV row.
func PlainFromStruct ¶
PlainFromStruct extracts specified fields from a struct and writes as TSV.
func PrintSlice ¶
PrintSlice writes a slice based on output mode.
func StatusPayload ¶
StatusPayload creates a simple status object for JSON output.
func SuccessPayload ¶
SuccessPayload creates a success status object.
func WithProgress ¶
WithProgress stores a progress session in context.
func WithSyncTimeline ¶ added in v0.1.3
func WithSyncTimeline(ctx context.Context, tl *SyncTimeline) context.Context
WithSyncTimeline stores a SyncTimeline in context.
func WithWriter ¶
WithWriter adds writer to context.
func WriteDetail ¶ added in v0.1.5
WriteDetail writes fields as aligned "Label: Value" pairs. Fields created with F() are skipped when their value is the zero value.
func WritePlain ¶
WritePlain writes values as tab-separated line.
Types ¶
type CopyTimeline ¶
type CopyTimeline struct {
// contains filtered or unexported fields
}
CopyTimeline renders a rolling timeline of copy stages to stderr. It satisfies migrate.CopyObserver via structural typing.
func NewCopyTimeline ¶
func NewCopyTimeline(ctx context.Context, dryRun bool) *CopyTimeline
NewCopyTimeline creates a timeline renderer. Call Close() when done.
func (*CopyTimeline) Close ¶
func (tl *CopyTimeline) Close()
Close stops the spinner goroutine and clears the active stage display. Does NOT render the footer — call Footer() first if the operation succeeded. Idempotent: safe to call multiple times.
func (*CopyTimeline) ErrorFooter ¶
func (tl *CopyTimeline) ErrorFooter(msg string)
ErrorFooter renders a closing error line (└ Error! <msg>). Clears the active spinner, stops the animation loop, and marks closed. Idempotent: second call is a no-op.
func (*CopyTimeline) Footer ¶
func (tl *CopyTimeline) Footer()
Footer renders the closing summary line (└ Done! Done in Xs). Call this only on success — omit on error so the footer doesn't mislead. Idempotent: second call is a no-op.
func (*CopyTimeline) Header ¶
func (tl *CopyTimeline) Header(from, to string)
Header prints the opening line of the timeline.
func (*CopyTimeline) PreparePrompt ¶ added in v0.1.13
func (tl *CopyTimeline) PreparePrompt()
PreparePrompt clears live spinner output before a blocking prompt is printed.
func (*CopyTimeline) StageDone ¶
func (tl *CopyTimeline) StageDone(name, summary string)
StageDone finalizes a stage with a summary.
func (*CopyTimeline) StageItem ¶
func (tl *CopyTimeline) StageItem(name, detail string, current, total int64)
StageItem updates the active stage's sub-detail.
func (*CopyTimeline) StageSkip ¶
func (tl *CopyTimeline) StageSkip(name, reason string)
StageSkip marks a stage as skipped with a reason.
func (*CopyTimeline) StageStart ¶
func (tl *CopyTimeline) StageStart(name string)
StageStart begins a new active stage with a spinner.
func (*CopyTimeline) StageWarning ¶ added in v0.1.13
func (tl *CopyTimeline) StageWarning(stage, msg string)
StageWarning records or prints a warning owned by one timeline stage.
func (*CopyTimeline) SubStageDone ¶
func (tl *CopyTimeline) SubStageDone(stage, sub, summary string)
SubStageDone records a completed sub-item within the active stage.
type Field ¶ added in v0.1.5
Field represents one row in a detail view.
type Mode ¶
Mode represents the output format mode.
func FromContext ¶
FromContext extracts output mode from context.
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError indicates invalid output mode configuration.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress renders lightweight human-only progress feedback on stderr.
func NewDisabledProgress ¶
func NewDisabledProgress() *Progress
NewDisabledProgress returns a no-op progress that silently discards all output. Use when a timeline renderer handles progress display instead.
func NewProgress ¶
NewProgress builds a human-mode stderr progress session for the current context.
func ProgressFromContext ¶
ProgressFromContext extracts the progress session from context.
func (*Progress) Close ¶
func (p *Progress) Close()
Close stops background rendering and leaves stderr clean.
type SyncCategory ¶ added in v0.1.3
SyncCategory describes one category for the timeline.
type SyncTimeline ¶ added in v0.1.3
type SyncTimeline struct {
// contains filtered or unexported fields
}
SyncTimeline renders category-grouped progress for theme push/sync.
func NewSyncTimeline ¶ added in v0.1.3
func NewSyncTimeline(ctx context.Context, mode, theme string, dryRun bool) *SyncTimeline
NewSyncTimeline creates a timeline renderer for theme push/sync.
func SyncTimelineFromContext ¶ added in v0.1.3
func SyncTimelineFromContext(ctx context.Context) *SyncTimeline
SyncTimelineFromContext retrieves the SyncTimeline from context, or nil.
func (*SyncTimeline) CategoryDone ¶ added in v0.1.3
func (tl *SyncTimeline) CategoryDone(index int)
CategoryDone finalizes a category, writing a permanent completion line.
func (*SyncTimeline) Close ¶ added in v0.1.3
func (tl *SyncTimeline) Close()
Close stops the animation goroutine and clears the active display. Idempotent.
func (*SyncTimeline) DeleteFailed ¶ added in v0.1.3
func (tl *SyncTimeline) DeleteFailed(displayPath, errorDetail string)
DeleteFailed records a delete failure.
func (*SyncTimeline) DeletesDone ¶ added in v0.1.3
func (tl *SyncTimeline) DeletesDone()
DeletesDone finalizes the delete phase with a permanent completion line.
func (*SyncTimeline) ErrorFooter ¶ added in v0.1.3
func (tl *SyncTimeline) ErrorFooter()
ErrorFooter renders a closing error summary line. Idempotent.
func (*SyncTimeline) FileDeleted ¶ added in v0.1.3
func (tl *SyncTimeline) FileDeleted()
FileDeleted records a successful delete.
func (*SyncTimeline) FileFailed ¶ added in v0.1.3
func (tl *SyncTimeline) FileFailed(displayPath, errorDetail string)
FileFailed records an upload failure. errorDetail is a pre-formatted string.
func (*SyncTimeline) FileSkipped ¶ added in v0.1.9
func (tl *SyncTimeline) FileSkipped()
FileSkipped records an intentionally skipped upload after user confirmation.
func (*SyncTimeline) FileUploaded ¶ added in v0.1.3
func (tl *SyncTimeline) FileUploaded()
FileUploaded records a successful upload and increments the category counter.
func (*SyncTimeline) Footer ¶ added in v0.1.3
func (tl *SyncTimeline) Footer()
Footer renders the closing success summary line. Idempotent.
func (*SyncTimeline) Header ¶ added in v0.1.3
func (tl *SyncTimeline) Header()
Header prints the opening line and starts the animation loop.
func (*SyncTimeline) NothingToDo ¶ added in v0.1.3
func (tl *SyncTimeline) NothingToDo()
NothingToDo renders a message when there are no files to process.
func (*SyncTimeline) PreparePrompt ¶ added in v0.1.9
func (tl *SyncTimeline) PreparePrompt()
PreparePrompt clears live spinner output before a blocking prompt is printed.
func (*SyncTimeline) RenderPlan ¶ added in v0.1.3
func (tl *SyncTimeline) RenderPlan(categories []SyncCategory, deleteCount int)
RenderPlan displays the dry-run plan without executing uploads.
func (*SyncTimeline) SetActiveDelete ¶ added in v0.1.3
func (tl *SyncTimeline) SetActiveDelete(displayPath string)
SetActiveDelete updates the spinner to show the file being deleted.
func (*SyncTimeline) SetActiveFile ¶ added in v0.1.3
func (tl *SyncTimeline) SetActiveFile(displayPath string)
SetActiveFile updates the spinner to show the file currently being uploaded.
func (*SyncTimeline) SetCategories ¶ added in v0.1.3
func (tl *SyncTimeline) SetCategories(categories []SyncCategory)
SetCategories initializes the category list and computes label alignment.
func (*SyncTimeline) StartCategory ¶ added in v0.1.3
func (tl *SyncTimeline) StartCategory(index int)
StartCategory begins a new active category with a spinner.
func (*SyncTimeline) StartDeletes ¶ added in v0.1.3
func (tl *SyncTimeline) StartDeletes(total int)
StartDeletes begins the delete phase with a spinner.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a simple table for human-readable output.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task represents one in-flight spinner, counter, or transfer.
func (*Task) ResetProgress ¶
func (t *Task) ResetProgress()
ResetProgress resets current progress and elapsed timing for a retry/replay attempt.
func (*Task) WrapReadCloser ¶
func (t *Task) WrapReadCloser(reader io.ReadCloser) io.ReadCloser
WrapReadCloser increments the task as data is read and preserves Close.
func (*Task) WrapReader ¶
WrapReader increments the task as data is read.
type Writer ¶
type Writer struct {
Out io.Writer
Err io.Writer
Mode Mode
NoTTY bool
Color string // "auto", "always", "never"
NoSpin bool // Disable spinner
}
Writer holds output configuration.
func DefaultWriter ¶
func DefaultWriter() *Writer
DefaultWriter returns a writer with default settings.
func WriterFromContext ¶
WriterFromContext extracts writer from context.