eldargab / easy-table

Nice text table for Node.js
314 stars 31 forks source link

Is there a way to wrap columns? #6

Closed kenperkins closed 10 years ago

kenperkins commented 11 years ago

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...

eldargab commented 11 years ago

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?

kenperkins commented 10 years ago

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

eldargab commented 10 years ago

Never mind :)