Socket
Socket
Sign inDemoInstall

listr2

Package Overview
Dependencies
20
Maintainers
1
Versions
229
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    listr2

Terminal task list reborn! Create beautiful CLI interfaces via easy and logical to implement task lists that feel alive and interactive.


Version published
Weekly downloads
15M
decreased by-0.75%
Maintainers
1
Install size
557 kB
Created
Weekly downloads
 

Package description

What is listr2?

The listr2 npm package is a powerful utility for creating beautiful and interactive command-line interfaces (CLI) with tasks lists. It allows developers to manage and execute multiple tasks in a structured and visually appealing way. It supports concurrent tasks, nested tasks, and customizable rendering, making it suitable for complex CLI applications.

What are listr2's main functionalities?

Basic Task Execution

This feature allows for the execution of a series of tasks, each represented by a title and a task function. The tasks are executed sequentially, and the progress is visually represented in the CLI.

const { Listr } = require('listr2');

const tasks = new Listr([
  {
    title: 'Task 1',
    task: () => Promise.resolve('First task result')
  },
  {
    title: 'Task 2',
    task: () => Promise.resolve('Second task result')
  }
]);

tasks.run().catch(err => console.error(err));

Concurrent Tasks

This feature demonstrates how to run tasks concurrently. By setting the 'concurrent' option to true, tasks within the same group are executed in parallel, improving performance for independent tasks.

const { Listr } = require('listr2');

const tasks = new Listr([
  {
    title: 'Concurrent Tasks',
    task: () => {
      return new Listr([
        {
          title: 'Task 1',
          task: () => Promise.resolve('First concurrent task result')
        },
        {
          title: 'Task 2',
          task: () => Promise.resolve('Second concurrent task result')
        }
      ], { concurrent: true });
    }
  }
]);

tasks.run().catch(err => console.error(err));

Nested Tasks

This feature showcases the ability to nest tasks within other tasks. It is useful for structuring complex workflows where tasks have sub-tasks, allowing for better organization and readability.

const { Listr } = require('listr2');

const tasks = new Listr([
  {
    title: 'Parent Task',
    task: () => {
      return new Listr([
        {
          title: 'Nested Task 1',
          task: () => Promise.resolve('First nested task result')
        },
        {
          title: 'Nested Task 2',
          task: () => Promise.resolve('Second nested task result')
        }
      ]);
    }
  }
]);

tasks.run().catch(err => console.error(err));

Other packages similar to listr2

Readme

Source

listr2

Pipeline Version Downloads Size Dependencies codecov

github sponsors opencollective

Create beautiful CLI interfaces via easy and logical to-implement task lists that feel alive and interactive.


Documentation

Read the documentation...

Demo

Demo

Keywords

FAQs

Last updated on 03 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc