eldargab/easy-table

Is there a way to wrap columns?

kenperkins opened this issue · 3 comments

I'd like to use Easy Table for Help text in a command line application.

Is there a way to have the output do something like:

Command Text
Help blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah
Foo blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah

And so forth...

Do you mean something like this ?

var Table = require('easy-table')

function cmd (name, opts) {
  console.log(name)
  var t = new Table
  opts(function (name, help) {
    t.cell('pad', '  ')
    t.cell('name', name)
    t.cell('help', help)
    t.newRow()
  })
  console.log(t.print())
  console.log()
}

cmd('install', function (opt) {
  opt('--help', 'Show help')
  opt('--foo', 'Foo option')
  opt('--bar', 'Enable bar')
})
install
    --help  Show help 
    --foo   Foo option
    --bar   Enable bar

Also just in case did you have a look at commander?

Hm, sorry I never updated this, I don't even recall the root problem :)

Never mind :)