Skip to content

Interactivity for your Go CLI

Typed prompts, coordinated progress and logs, and explicit defaults for automation. Keep your application’s control flow.

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)
Prompts, spinners, progress and logs sharing one terminal