Documentation
¶
Index ¶
- Variables
- func ConfirmRedownload(filename string) bool
- func DisplayProgressBar() bool
- func Errorf(format string, a ...any) (n int, err error)
- func Errorln(a ...any) (n int, err error)
- func IsTerminal(f *os.File) bool
- func NewProgram(numConns int) *tea.Program
- func NewTUIModel(numConns int, willVerify bool, batchCurrent, batchTotal int, ...) tuiModel
- func PrintHelp()
- func PrintVerifySummary(ok bool, detail string)
- func Printf(format string, a ...any) (n int, err error)
- func ResumePrompt(taskName string, downloaded, total int64) (bool, error)
- func RunWithTUI(opts RunOptions, fn func() error) error
- func ShowMessage(msgType MessageType, title, message string)
- func Warnf(format string, a ...any) (n int, err error)
- type Console
- type DownloadDoneMsg
- type DownloadErrorMsg
- type DownloadStartMsg
- type JoinDoneMsg
- type JoinProgressMsg
- type JoinStartMsg
- type LogMsg
- type MessageType
- type PartDoneMsg
- type PartProgressMsg
- type RunOptions
- type SkippingMsg
- type StoppingMsg
- type UI
- type VerifyDoneMsg
- type VerifyStartMsg
Constants ¶
This section is empty.
Variables ¶
var ( Stdout = colorable.NewColorableStdout() Stderr = colorable.NewColorableStderr() DefaultUI = Console{Stdout: Stdout, Stderr: Stderr} // Log is the global structured console logger used when the TUI is inactive. // It uses charmbracelet/log with custom lipgloss styles matching the TUI palette. Log *charmlog.Logger )
var DisplayProgress = true
DisplayProgress controls whether the TUI progress bar is shown. Set to false in tests to disable TUI output.
var Program *tea.Program
Program is the global tea.Program; goroutines call Program.Send() to deliver messages.
Functions ¶
func ConfirmRedownload ¶
ConfirmRedownload shows a styled huh confirmation prompt asking whether to overwrite an existing file. Returns true when the user says yes (or when stdout is not a terminal, in which case the download proceeds silently).
func DisplayProgressBar ¶
func DisplayProgressBar() bool
DisplayProgressBar returns true when running in interactive TTY mode.
func IsTerminal ¶
IsTerminal checks if f is connected to a real TTY.
func NewProgram ¶
NewProgram creates and starts a new Bubble Tea program for the TUI.
func NewTUIModel ¶
func NewTUIModel(numConns int, willVerify bool, batchCurrent, batchTotal int, onSkip, onQuit func()) tuiModel
NewTUIModel creates a new TUI model for the given number of connections. batchCurrent and batchTotal are 1-based; pass 0,0 when not in batch mode. onSkip is non-nil only in batch mode and is invoked when the user presses 's'. onQuit is invoked on 'q' / 'ctrl+c'; both default to no-ops if nil.
func PrintVerifySummary ¶
PrintVerifySummary writes a styled one-line verify result to the terminal using charmbracelet/log (works after the TUI alt-screen has closed).
func ResumePrompt ¶
ResumePrompt shows an animated TUI prompt asking whether to resume a partial download. Returns true if user wants to resume, false to start fresh.
func RunWithTUI ¶
func RunWithTUI(opts RunOptions, fn func() error) error
RunWithTUI starts a Bubble Tea program for interactive TTY sessions and runs fn in a background goroutine. Falls back to plain execution when not in a TTY. Returns the error returned by fn (or recovered from a panic inside it), so callers can distinguish skip vs abort vs failure.
func ShowMessage ¶
func ShowMessage(msgType MessageType, title, message string)
ShowMessage displays a styled message box and returns immediately.
Types ¶
type DownloadDoneMsg ¶
type DownloadDoneMsg struct{}
DownloadDoneMsg signals the entire pipeline (download + join + optional verify) finished.
type DownloadErrorMsg ¶
type DownloadErrorMsg struct{ Err error }
DownloadErrorMsg signals a fatal download error.
type DownloadStartMsg ¶
DownloadStartMsg is sent once download metadata is known.
type JoinProgressMsg ¶
type JoinProgressMsg struct{ Current int }
JoinProgressMsg carries joining progress.
type JoinStartMsg ¶
type JoinStartMsg struct{ Total int }
JoinStartMsg signals the file-joining phase started.
type MessageType ¶
type MessageType int
MessageBox renders a styled message box that fits the modem theme.
const ( MessageInfo MessageType = iota MessageWarning MessageError MessageSuccess )
type PartDoneMsg ¶
type PartDoneMsg struct{ Index int }
PartDoneMsg signals a chunk finished downloading successfully.
type PartProgressMsg ¶
PartProgressMsg carries incremental progress for one chunk.
type RunOptions ¶
type RunOptions struct {
// Ctx is observed for external cancellation (e.g. SIGINT routed through
// signal.NotifyContext at main). When Ctx is cancelled, RunWithTUI
// surfaces a "stopping…" overlay and waits for fn to drain.
Ctx context.Context
// OnSkip is called when the user presses 's' (batch mode only).
OnSkip func()
// OnQuit is called when the user presses 'q' / 'ctrl+c'.
OnQuit func()
NumConns int
WillVerify bool
BatchCurrent int
BatchTotal int
}
RunOptions configures a TUI session.
type SkippingMsg ¶
type SkippingMsg struct{}
SkippingMsg overlays a "skipping" panel for the current batch item.
type StoppingMsg ¶
type StoppingMsg struct {
// Reason renders inside the stopping panel; e.g. "Aborted by user".
Reason string
}
StoppingMsg is sent when an external cancellation (e.g. SIGINT routed through signal.NotifyContext) has been requested. The TUI overlays a "stopping" panel until the worker goroutine reports completion.
type UI ¶
type UI interface {
Printf(format string, a ...any) (n int, err error)
Println(a ...any) (n int, err error)
Errorf(format string, a ...any) (n int, err error)
Errorln(a ...any) (n int, err error)
}
UI represents simple IO output.
type VerifyDoneMsg ¶
VerifyDoneMsg signals GPG verification has completed.
type VerifyStartMsg ¶
type VerifyStartMsg struct{}
VerifyStartMsg signals GPG signature verification has begun.