Skip to content

golist

GitHub tag (latest SemVer) Go Reference GitHub Workflow Status GitHub go.mod Go version GitHub Go Report Card Sourcegraph codecov

created by Austin Poor

About

A terminal task-list tool for Go. Inspired by the Node package listr.

Also check out the GitHub repo or the Go docs.

Feature Overview

  • Multi-line updating lists print to the console
  • Status updates live (with spinners while processing)
  • Nested task groups
  • Optionally run tasks concurrently
  • Check if tasks should be skipped or should fail
  • Safely print to stdout while the list is being displayed
  • Update the task's message while running
  • Truncate text output
  • Optionally expand/collapse a task-group's subtasks when not running
  • Optionally skip remaining tasks if one fails in a list or sub-group

Installation

go get github.com/a-poor/golist

Dependencies

  • Standard library
  • Go-MultiError, for returning multiple sub-task errors

Quickstart

Here's a quick example of golist in action:

// Create a new list
l := golist.NewList()

// Add some tasks
l.AddTask(golist.NewTask("Get a pen", func(c golist.TaskContext) error {
    time.Sleep(time.Second)
    return nil
}))
l.AddTask(golist.NewTask("Get some paper", func(c golist.TaskContext) error {
    time.Sleep(time.Second)
    return nil
}))
l.AddTask(golist.NewTask("Write a novel", func(c golist.TaskContext) error {
    time.Sleep(time.Second)
    return nil
}))

// Run the tasks
l.RunAndWait()

License

MIT

Contributing

Pull requests are super welcome! For major changes, please open an issue first to discuss what you would like to change. And please make sure to update tests as appropriate.

Or... feel free to just open an issue with some thoughts or suggestions or even just to say Hi and tell me if this library has been helpful!