lib/styled.js
function styledObject (obj, keys) {
  let keyLengths = Object.keys(obj).map(key => key.toString().length)
  let maxKeyLength = Math.max.apply(Math, keyLengths) + 2
  function pp (obj) {
    if (typeof obj === 'string' || typeof obj === 'number') {
      return obj
    } else if (typeof obj === 'object') {
      return Object.keys(obj).map(k => k + ': ' + util.inspect(obj[k])).join(', ')
    } else {
      return util.inspect(obj)
    }
  }
  function logKeyValue (key, value) {
    cli.log(`${key}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value))
  }
  for (var key of (keys || Object.keys(obj).sort())) {
    let value = obj[key]
    if (Array.isArray(value)) {
      if (value.length > 0) {
        logKeyValue(key, value[0])
        for (var e of value.slice(1)) {
          cli.log(' '.repeat(maxKeyLength) + pp(e))
        }
      }
    } else if (value !== null && value !== undefined) {
      logKeyValue(key, value)
    }
  }
}
function styledObject (obj, keys) {
  let keyLengths = Object.keys(obj).map(key => key.toString().length)
  let maxKeyLength = Math.max.apply(Math, keyLengths) + 2
  function pp (obj) {
    if (typeof obj === 'string' || typeof obj === 'number') {
      return obj
    } else if (typeof obj === 'object') {
      return Object.keys(obj).map(k => k + ': ' + util.inspect(obj[k])).join(', ')
    } else {
      return util.inspect(obj)
    }
  }
  function logKeyValue (key, value) {
    cli.log(`${key}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value))
  }
  for (var key of (keys || Object.keys(obj).sort())) {
    let value = obj[key]
    if (Array.isArray(value)) {
      if (value.length > 0) {
        logKeyValue(key, value[0])
        for (var e of value.slice(1)) {
          cli.log(' '.repeat(maxKeyLength) + pp(e))
        }
      }
    } else if (value !== null && value !== undefined) {
      logKeyValue(key, value)
    }
  }
}
function styledObject ( obj , keys ) { let keyLengths = Object . keys ( obj ) . map ( key => key . toString ( ) . length ) let maxKeyLength = Math . max . apply ( Math , keyLengths ) + 2 function pp ( obj ) { if ( typeof obj === 'string' || typeof obj === 'number' ) { return obj } else if ( typeof obj === 'object' ) { return Object . keys ( obj ) . map ( k => k + ': ' + util . inspect ( obj [ k ] ) ) . join ( ', ' ) } else { return util . inspect ( obj ) } } function logKeyValue ( key , value ) { cli . log ( ` ${ key } ` + ' ' . repeat ( maxKeyLength - key . length - 1 ) + pp ( value ) ) } for ( var key of ( keys || Object . keys ( obj ) . sort ( ) ) ) { let value = obj [ key ] if ( Array . isArray ( value ) ) { if ( value . length > 0 ) { logKeyValue ( key , value [ 0 ] ) for ( var e of value . slice ( 1 ) ) { cli . log ( ' ' . repeat ( maxKeyLength ) + pp ( e ) ) } } } else if ( value !== null && value !== undefined ) { logKeyValue ( key , value ) } } }
styledObject logs an object in a consistent columnar style

@example
styledObject({name: "myapp", collaborators: ["user1@example.com", "user2@example.com"]})
Collaborators: user1@example.com
user2@example.com
Name:          myapp

@param {obj} object data to print
@param {keys} optional array of keys to sort/filter output
@returns {null}
styledObject logs an object in a consistent columnar style