GitHub - GoogleCloudPlatform/terminus: terminus is a Go framework for building terminal-style user interfaces that run in web browsers. (original) (raw)

Terminus

A Go framework for building terminal-style user interfaces that run in web browsers. Terminus brings the simplicity and power of terminal UIs to the web, using a Model-View-Update (MVU) architecture similar to Elm.

NOTEThis project is a demonstration of vibe coding intended to provide a trustworthy and verifiable example that developers and researchers can use. It is not intended for use in a production environment.

This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.

✨ Features

Widget Library

TextInput

Full-featured text input with:

List

Scrollable lists with:

Table

Data tables with:

Spinner

Loading indicators with:

🚀 Quick Start

Installation

go get github.com/GoogleCloudPlatform/terminus

Hello World Example

package main

import ( "fmt" "log"

"github.com/GoogleCloudPlatform/terminus/pkg/terminus"
"github.com/GoogleCloudPlatform/terminus/terminus/style"

)

type HelloWorld struct { count int }

func (h *HelloWorld) Init() terminus.Cmd { return nil }

func (h *HelloWorld) Update(msg terminus.Msg) (terminus.Component, terminus.Cmd) { switch msg := msg.(type) { case terminus.KeyMsg: switch msg.Type { case terminus.KeyUp: h.count++ case terminus.KeyDown: h.count-- case terminus.KeyEscape: return h, terminus.Quit } } return h, nil }

func (h *HelloWorld) View() string { title := style.New().Bold(true).Foreground(style.Cyan).Render("Terminus Counter") counter := style.New().Bold(true).Render(fmt.Sprintf("Count: %d", h.count)) help := style.New().Faint(true).Render("↑/↓ to change • ESC to quit")

return fmt.Sprintf("%s\n\n%s\n\n%s", title, counter, help)

}

func main() { program := terminus.NewProgram( func() terminus.Component { return &HelloWorld{} }, terminus.WithAddress(":8080"), )

fmt.Println("Starting on http://localhost:8080")
if err := program.Start(); err != nil {
    log.Fatal(err)
}
program.Wait()

}

📚 Documentation

🎮 Examples

Explore our example applications:

Example Description Run Command
Hello World Simple starter app go run ./examples/hello/
Todo List Task management with persistence go run ./examples/todo/
Chat Real-time messaging go run ./examples/chat/
Dashboard Complex layouts go run ./examples/dashboard/
Widgets All widgets showcase go run ./examples/widgets/
Text Input Forms with validation go run ./examples/textinput/
Commands Advanced command usage go run ./examples/commands/
Layout Layout system demo go run ./examples/layout/
Gemini Chat AI chat with Google Gemini go run ./examples/gemini_chat/

All examples run on http://localhost:8890 by default.

🏗️ Architecture

Terminus uses a unique server-side architecture:

┌─────────────┐         WebSocket        ┌─────────────┐
│   Browser   │ ◄──────────────────────► │  Go Server  │
│             │       JSON Messages      │             │
│ ┌─────────┐ │                          │ ┌─────────┐ │
│ │  Thin   │ │                          │ │   MVU   │ │
│ │ Client  │ │                          │ │ Engine  │ │
│ └─────────┘ │                          │ └─────────┘ │
└─────────────┘                          └─────────────┘

Key benefits:

🛠️ Development Status

✅ Completed

🚧 In Progress

📋 Planned

🤝 Contributing

We welcome contributions! Areas where you can help:

Please see our Contributing Guide (coming soon).

📄 License

This project is licensed under the Apache 2.0 License.

🙏 Acknowledgments

Terminus is inspired by:


Happy coding! 🚀