Listr

listr

Terminal task list.

listr is one of those cheeky 💄 modules for your CLI apps.

Below is the gist of this module:

  • listr accepts an array of tasks, where each task in a object consisting of title (string) and task (method).

  • If a task returns, it means the task was completed succesfully.

  • If a task throws an error, the task failed.

  • Task can be async by returning a Promise.

  • Task can be an Observable.

  • Task can also be a stream, which is in-turn converted to an Observable.

  • An instance of listr has add(task), task and run methods. (Names are self explanatory?)

Get it: npm install --save listr

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
const tasks = new Listr([
  {
      title: 'Success',
      task: () => 'Foo'
  },
  {
      title: 'Failure',
      task: () => {
          throw new Error('Bar')
      }
  }
]);
1
2
3
tasks.run().catch(err => {
  console.error(err);
});

GIF FTW!

listr

Suggest a module

Comments