Interactivity for your Go CLI
Typed prompts, coordinated progress and logs, and explicit defaults for automation. Keep your application’s control flow.
Keep your architecture
Call widgets from ordinary Go functions, with contexts, readers, writers and typed results.
One terminal coordinator
Prompts and progress coexist with logs routed through tui.Stderr().
Ready for automation
Without a TTY, prompts validate explicit defaults without reading input; progress becomes structured logs.
setupLogger()
ctx, cancel := context.WithCancel(context.Background())
logDone := startWordLogger(ctx)
progressDone := startProgress(ctx)
defer func() {
cancel()
<-progressDone
<-logDone
}()
spinners, err := tui.NewSpinners(ctx)
if errors.Is(err, io.EOF) || errors.Is(err, tui.ErrNoTTY) {
return
}
if err != nil {
panic(err)
}
defer spinners.Close()
runInteractiveExample(ctx, spinners)