Home

Awesome

go-glint Godoc

Glint is a component-based UI framework specifically targeted towards command-line interfaces. This allows you to create highly dynamic CLI interfaces using shared, easily testable components. Glint uses a Flexbox implementation to make it easy to lay out components in the CLI, including paddings, margins, and more.

API Status: Unstable. We're still actively working on the API and may change it in backwards incompatible ways. See the roadmap section in particular for work that may impact the API. In particular, we have integrated this library into Waypoint, and the experience of using this library in the real world will likely drive major changes.

Example

The example below shows a simple dynamic counter:

func main() {
	var counter uint32
	go func() {
		for {
			time.Sleep(100 * time.Millisecond)
			atomic.AddUint32(&counter, 1)
		}
	}()

	d := glint.New()
	d.Append(
		glint.Style(
			glint.TextFunc(func(rows, cols uint) string {
				return fmt.Sprintf("%d tests passed", atomic.LoadUint32(&counter))
			}),
			glint.Color("green"),
		),
	)
	d.Render(context.Background())
}

Output:

Example

Roadmap

Glint is still an early stage project and there is a lot that we want to improve on. This may introduce some backwards incompatibilities but we are trying to stabilize the API as quickly as possible.

Thanks

This library is heavily inspired by the Ink project. I saw this project and thought that having a central render loop along with a full layout engine was a fantastic idea. Most of my projects are in Go so I wanted to be able to realize these benefits with Go. Thank you!