github.com/zmwangx/mrun

Embedded TUI multi-command runner


License
MIT
Install
go get github.com/zmwangx/mrun

Documentation

mrun

Go Reference

Embedded TUI multi-command runner based on bubbletea.

Demo

Sometimes you want to run multiple commands in parallel and let the user monitor their progress in real time. tmux is an obvious option but it's highly unusual to spawn tmux session/windows as a third party program, and you can't control spawned commands as effectively when they're children of tmux. mrun lets you integrate a TUI grid right inside your program, neatly solving the problem.

See demo.go for the code used to generate the demo image.

Features

Supports:

  • Things you expect from a TUI built in the 2020s: Unicode support (CJK-aware), color.
  • Commands are run in ptys, don't need to mess with flags to reenable interactive features.
  • Each command has a scroll buffer.
  • Carriage returns are handled gracefully, so commands with basic progress bars work as expected.
  • Mouse support: click to focus, mouse wheel to scroll.
  • Terminal resizing is handled gracefully.

Does not support:

  • Input: commands can't receive user input.
  • Terminal emulation: if your command itself is a TUI program using escape sequences to write to specific coordinates on screen, then it won't work correctly and will likely mess up everything. The output buffer implementation of mrun is basic, far from a full blown terminal emulator like tmux. Try to use the batch mode of your program if it has one (e.g. by piping its output to cat).
  • Integration into larger bubbletea applications: currently not exposed.

Documentation

See https://pkg.go.dev/github.com/zmwangx/mrun.