tasktree-cli

Simple terminal task tree - helps you keep track of your tasks in a tree structure.

MIT 35 个版本
安装
npm install tasktree-cli
yarn add tasktree-cli
pnpm add tasktree-cli
bun add tasktree-cli
README

Package logo

Build Status npm Standard Shared Config

Simple terminal task tree - helps you keep track of your tasks in a tree structure.

Install

npm install tasktree-cli

Usage

import TaskTree from 'tasktree-cli';

const tree = TaskTree.tree();

// start task tree log update in terminal
tree.start();

// create tasks
const task1 = tree.add('{underline Task {bold #1}}');
const task2 = tree.add('Task {bold #2}');
const task3 = task2.add('Subtask...');
const tpl = ':bar :rate/bps {cyan.bold :percent} :etas';
// create progress bars
const bars = [task3.bar(tpl), task3.bar(tpl), task3.bar(tpl)];

// ... whatever
let once = false;
const promises = [50, 75, 200].map((ms, i) => {
  return new Promise(resolve => {
    const handle = setInterval(() => {
      const bar = bars[i];

      if (bar) {
        if (once) {
          if (bar.percent >= 50) {
            bar.skip();
          } else {
            bar.fail();
          }
        } else {
          once = bar.tick(Math.random() * 10).isCompleted;
        }
      }

      if (once) {
        clearInterval(handle);
        resolve('');
      }
    }, ms);
  });
});

Promise.all(promises).then(() => {
  // skip task
  task3.skip('Subtask skipped');
  // log info message in Task #2, complete task
  task2.log('Informational message').complete();
  // log warning and error in Task #1, fail it
  task1.warn('Warning message').error(new Error('Something bad happened'), true);
  // stop task tree log update
  tree.stop();
});

TaskTree uses chalk-template to style text and supports formatting as a tagged template literal:

const task = new Task('{underline.cyan.bold Awesome task}');

If you are using braces in a formatted string, use \\ to escape it:

const task = new Task('{underline.cyan.bold \\{Awesome\\} task}');

API

Read the API documentation for more information.

版本列表
8.1.0 2024-02-14
8.0.0 2023-08-19
7.0.0 2022-11-26
6.0.5 2022-04-20
6.0.4 2022-04-04
6.0.3 2022-03-17
6.0.2 2022-02-17
6.0.1 2022-01-16
6.0.0 2022-01-03
5.1.0 2021-11-27
5.0.1 2021-05-06
5.0.0 2021-05-03
4.0.3 2021-04-30
4.0.1 2021-03-04
4.0.0 2021-03-04
3.0.1 2020-01-30
3.0.0 2020-01-29
2.0.2 2019-09-07
2.0.1 2019-09-07
2.0.0 2019-09-04
1.3.0 2019-08-14
1.2.6 2019-08-12
1.2.5 2019-08-11
1.2.4 2019-08-08
1.2.3 2019-07-28
1.2.2 2019-07-18
1.2.1 2019-06-24
1.2.0 2019-06-23
1.1.3 2019-06-11
1.1.2 2019-05-28
1.1.1 2019-05-27
1.1.0 2019-05-26
1.0.0 2019-05-20
0.9.1 2019-05-14
0.9.0 2019-05-14