hustcer / star

A STock Analysis and Research tool for terminal(cli) users. 技术控和命令行爱好者的 A 股辅助分析工具。
MIT License
955 stars 247 forks source link

Use `text-table` to align console output #29

Closed hustcer closed 9 years ago

hustcer commented 9 years ago

Use text-table to align console output

hustcer commented 9 years ago

Delay

hustcer commented 9 years ago

text-table does not work not well with Unicode characters, see issue

hustcer commented 9 years ago

You need to pass a string length function that would take wide characters into account.

var table = require('text-table'),
    wcwidth = require('wcwidth');
var t = table([
    [ '中国好声音', '1024000' ],
    [ '舞蹈', '33450' ],
    [ 'foo', '1006' ],
    [ '中文对齐有点儿问题哦', '45.08' ]
], {
  align: [ 'l', 'r' ],
  stringLength: wcwidth
});

console.log(t);
hustcer commented 8 years ago

This one will be better: https://github.com/timoxley/columnify