Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

a-poor/golist

Repository files navigation

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

A terminal task-list tool for Go. Inspired by the Node package listr and the AWS Copilot CLI.

Check out the documentation here! NOTE: The docs site is slightly out of date since some cool new features have been added! Check out this README for updated info and then check back with the docs later!

In a rush? Check out the Example section or the Examples directory!

Features

  • 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

Example

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()

Check out the examples folder for more examples of golist in action!

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!