快速构建好看的命令行界面的Node.js工具包:clui

jopen 10年前

这是一个Node.js的工具包,用于快速构建好看的命令行界面,可以响应不断变化的终端尺寸。它还包括以下使用方便组件:

  • Gauges
  • Progress Bars
  • Sparklines
  • Spinners

var CLI = require('clui'),      clc = require('cli-color');    var Line          = CLI.Line,      LineBuffer    = CLI.LineBuffer;    var outputBuffer = new LineBuffer({    x: 0,    y: 0,    width: 'console',    height: 'console'  });    var message = new Line(outputBuffer)    .column('Title Placehole', 20, [clc.green])    .fill()    .store();    var blankLine = new Line(outputBuffer)    .fill()    .store();    var header = new Line(outputBuffer)    .column('Suscipit', 20, [clc.cyan])    .column('Voluptatem', 20, [clc.cyan])    .column('Nesciunt', 20, [clc.cyan])    .column('Laudantium', 11, [clc.cyan])    .fill()    .store();    var line;  for(var l = 0; l < 20; l++)  {    line = new Line(outputBuffer)      .column((Math.random()*100).toFixed(3), 20)      .column((Math.random()*100).toFixed(3), 20)      .column((Math.random()*100).toFixed(3), 20)      .column((Math.random()*100).toFixed(3), 11)      .fill()      .store();  }    outputBuffer.output();

项目主页:http://www.open-open.com/lib/view/home/1423551092311