https://github.com/tinywasm/devtui
Reusable terminal user interface abstraction for Go development tools. Built on top of bubbletea, DevTUI provides a pre-configured, minimalist interface where you can inject different handlers to display organized messages and interactions.
https://github.com/tinywasm/devtui
bubbletea golang golang-application golang-library tui tui-app
Last synced: 5 months ago
JSON representation
Reusable terminal user interface abstraction for Go development tools. Built on top of bubbletea, DevTUI provides a pre-configured, minimalist interface where you can inject different handlers to display organized messages and interactions.
- Host: GitHub
- URL: https://github.com/tinywasm/devtui
- Owner: tinywasm
- License: mit
- Created: 2025-03-11T15:17:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-14T17:29:37.000Z (5 months ago)
- Last Synced: 2026-01-14T21:53:41.422Z (5 months ago)
- Topics: bubbletea, golang, golang-application, golang-library, tui, tui-app
- Language: Go
- Homepage:
- Size: 5.67 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changefunc_control_test.go
- License: LICENSE
Awesome Lists containing this project
README
# DevTUI
DevTUI is a **pure display layer** built on Bubbletea that organizes messages from business logic into a clean terminal interface.
## 🎯 Design Philosophy (Consumer-Driven)
DevTUI follows **consumer-driven interface design**: your application defines the UI interface, and DevTUI implements it. This ensures:
- **Zero Coupling**: Business logic never imports `devtui`.
- **High Testability**: Easily mock UI dependencies.
- **Pluggability**: Swap UI implementations without changing core logic.
### Integration Interface
Define this in your application to use DevTUI:
```go
type TuiInterface interface {
NewTabSection(title, description string) any
AddHandler(handler any, timeout time.Duration, color string, tabSection any)
RemoveTabSection(section any) // Dynamic removal
Start(args ...any) // Optional *sync.WaitGroup support
RefreshUI()
ReturnFocus() error
}
```
## 🚀 Quick Start
```go
func main() {
tui := devtui.NewTUI(&devtui.TuiConfig{AppName: "Demo", ExitChan: make(chan bool)})
// 1. Create a section
ops := tui.NewTabSection("Operations", "System Tasks")
// 2. Add handlers (DevTUI detects implemented interfaces automatically)
tui.AddHandler(&MyHandler{}, 5*time.Second, "#10b981", ops)
// 3. Optional: Remove section dynamically
// tui.RemoveTabSection(ops)
tui.Start()
}
```
## 🧩 Handler Interfaces
DevTUI detects 5 specialized interfaces to determine how to display and interact with your handlers:
| Interface | Purpose | Key Methods |
|-----------|---------|-------------|
| **Display** | Read-only info | `Name()`, `Content()` |
| **Edit** | Interactive input | `Label()`, `Value()`, `Change(newVal)` |
| **Execution** | Action buttons | `Label()`, `Execute()` |
| **Interactive** | Rich interaction | `WaitingForUser()`, `Value()`, `Change()` |
| **Loggable** | Auto-logging | `SetLog(func(...any))` |
### 💡 Clean Terminal Policy
Handlers implementing `Loggable` receive a logger. DevTUI only displays the **most recent message** per handler to keep the view focused. Full history is preserved for debugging.
#### 🔄 Animated Progress Logs
For long-running operations, you can use the `LogOpen` and `LogClose` prefixes as the **first argument** to the logger. This triggers an auto-animated spinner and groups messages under the same line.
```go
// Start animation (use "[..." literal or devtui.LogOpen)
handler.log("[...", "Deploying to production")
// ... long operation ...
// Stop animation and show final result (use "...]" literal or devtui.LogClose)
handler.log("...]", "Deployment complete")
```
## ⌨️ Navigation & Shortcuts
- **Tab / Shift+Tab**: Switch tabs
- **Arrows**: Navigate fields / Scroll view
- **Enter / Esc**: Execute (Edit) / Cancel
- **Global Shortcuts**: Handlers can implement `Shortcuts() []map[string]string` to register keys (e.g., 't' for test) that work from any tab.
## 📚 Further Reading
- [→ Why DevTUI? (Full Purpose)](docs/DESCRIPTION.md)
- [→ Complete Demo Example](example/demo/main.go)
- [→ Implementation Examples](example/)
---
[Contributing](https://github.com/tinywasm/cdvelop/blob/main/CONTRIBUTING.md) | Built with [Bubbletea](https://github.com/charmbracelet/bubbletea)