{"name":"cliff","description":"Your CLI formatting friend.","version":"0.1.2","author":{"name":"Nodejitsu","email":"info@nodejitsu.com"},"repository":{"type":"git","url":"git://github.com/nodejitsu/cliff.git"},"keywords":["cli","logging","tools","winston"],"dependencies":{"colors":"0.x.x","eyes":"0.1.x","winston":"0.3.x"},"devDependencies":{"vows":"0.5.x"},"main":"./lib/cliff","scripts":{"test":"vows test/*-test.js --spec"},"engines":{"node":">= 0.4.0"},"_id":"cliff@0.1.2","_engineSupported":true,"_npmVersion":"1.0.10","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"a8ade9fe923222017d26741e4cca1e5b421348bc","tarball":"http://registry-npm.ywwl.com/cliff/download/cliff-0.1.2.tgz","integrity":"sha512-v7wQw6rqCMzqcp7jnW8eeUeLlo21WEu+ndpWSVWeqdr8O2pTHYbLO3hwBQXFz1v5b1Nn+SIrShn+HbE56f5pLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDDdSLOVX3JqbfrdGoLsgDsXUNxq2pJ7ngkniWd/KknswIgSP50lNnlXIHwcyLkxU8JV1JjxvnMdv4QG6SGNu+CCdA="}],"size":5498,"noattachment":false,"key":"/cliff/-/cliff-0.1.2.tgz"},"directories":{},"readme":"# cliff\n\nCLI output formatting tools: \"Your CLI Formatting Friend\".\n\n## Installation\n\n### Installing npm (node package manager)\n```\n  curl http://npmjs.org/install.sh | sh\n```\n\n### Installing cliff\n```\n  [sudo] npm install cliff\n```\n\n## Usage\nThere are a number of methods available in Cliff for common logging tasks in command-line tools. If you're looking for more usage, checkout the [examples in this repository][3]:\n\n1. Logging rows of data\n2. Inspecting Objects\n\n### Logging rows of data\n\n**cliff.stringifyRows(rows[, colors])**\n\nTakes a set of Arrays and row headers and returns properly formatted and padded rows. Here's a sample:\n\n``` js\n  var cliff = require('../lib/cliff');\n\n  var rows = [\n    ['Name',  'Flavor',    'Dessert'],\n    ['Alice', 'cherry',    'yogurt'],\n    ['Bob',   'carmel',    'apples'],\n    ['Joe',   'chocolate', 'cake'],\n    ['Nick',  'vanilla',   'ice cream']\n  ];\n\n  console.log(cliff.stringifyRows(rows, ['red', 'blue', 'green']));\n```\n\n![output from string-rows.js][string-rows]\n\n**cliff.putRows(level, rows[, colors])**\n\nThe `putRows` method is a simple helper that takes a set of Arrays and row headers and logs properly formatted and padded rows (logs `stringifyRows` to [winston][0]). Here's a quick sample:\n\n``` js\n  var cliff = require('../lib/cliff');\n\n  var rows = [\n    ['Name',  'Flavor',    'Dessert'],\n    ['Alice', 'cherry',    'yogurt'],\n    ['Bob',   'carmel',    'apples'],\n    ['Joe',   'chocolate', 'cake'],\n    ['Nick',  'vanilla',   'ice cream']\n  ];\n\n  cliff.putRows('data', rows, ['red', 'blue', 'green']);\n```\n\nThe resulting output on the command-line would be:\n\n![output from put-rows.js][put-rows]\n\n**cliff.stringifyObjectRows(objs, properties[, colors])**\n*used to be: cliff.rowifyObjects(objs, properties, colors)*\n\nTakes a set of Objects and the properties to extract from them and returns properly formatted and padded rows. Here's a sample:\n\n``` js\n  var cliff = require('../lib/cliff');\n\n  var objs = [], obj = {\n    name: \"bazz\",\n    address: \"1234 Nowhere Dr.\",\n  };\n\n  for (var i = 0; i < 10; i++) {\n    objs.push({\n      name: obj.name,\n      address: obj.address,\n      id: Math.random().toString()\n    });\n  }\n\n  console.log(cliff.stringifyObjectRows(objs, ['id', 'name', 'address'], ['red', 'blue', 'green']));\n```\n\n![output from string-object-rows.js][string-object-rows]\n\n**cliff.putObjectRows(level, objs, properties[, colors])**\n\nTakes a set of Objects and the properties to extract from them and it will log to the console. (it prints `stringifyObjectRows` with [winston][0]). Here's a sample:\n\n``` js\n  var cliff = require('../lib/cliff');\n\n  var objs = [], obj = {\n    name: \"bazz\",\n    address: \"1234 Nowhere Dr.\",\n  };\n\n  for (var i = 0; i < 10; i++) {\n    objs.push({\n      name: obj.name,\n      address: obj.address,\n      id: Math.random().toString()\n    });\n  }\n\n  cliff.putObjectRows('data', objs, ['id', 'name', 'address']);\n```\n\n![output from string-object-rows.js][string-object-rows]\n\n**Colors Parameter**\n\nThe `colors` parameter is an array that colors the first row. It uses the [colors.js][2]. You can use any of those.\n\n``` js\n  var cliff = require('../lib/cliff');\n\n  var rows = [\n    ['Name',        'Flavor',              'Dessert'],\n    ['Alice'.grey,  'cherry'.cyan,         'yogurt'.yellow],\n    ['Bob'.magenta, 'carmel'.rainbow,      'apples'.white],\n    ['Joe'.italic,  'chocolate'.underline, 'cake'.inverse],\n    ['Nick'.bold,   'vanilla',             'ice cream']\n  ];\n\n  cliff.putRows('data', rows, ['red', 'blue', 'green']);\n```\n\nThe resulting output on the command-line would be:\n\n![output from puts-rows-colors.js][put-rows-colors]\n\n### Inspecting Objects\n\n**cliff.inspect(obj)**\n\nThe `inspect` method is a lightweight wrapper to a pre-configured [eyes][1] inspector. If you wish to change the coloring of objects that are logged using `cliff` you only need to override `cliff.inspect` with a new [eyes][1] inspector. Here is how to use it:\n\n``` js\n  var cliff = require('../lib/cliff');\n\n  console.log(cliff.inspect({\n    literal: \"bazz\",\n    arr: [\n      \"one\",\n      2,\n    ],\n    obj: {\n      host: \"localhost\",\n      port: 5984,\n      auth: {\n        username: \"admin\",\n        password: \"password\"\n      }\n    }\n  }));\n```\n\n![output from inspect.js][inspect]\n\n**cliff.putObject(obj, [rewriters, padding])**\n\nThe `putObject` method is a simple helper function for prefixing and styling inspected object output from [eyes][1]. Here's a quick sample:\n\n``` js\nvar cliff = require('cliff');\n\ncliff.putObject({\n  literal: \"bazz\",\n  arr: [\n    \"one\",\n    2,\n  ],\n  obj: {\n    host: \"localhost\",\n    port: 5984,\n    auth: {\n      username: \"admin\",\n      password: \"password\"\n    }\n  }\n});\n```\n\nThe resulting output on the command-line would be: \n\n![output from put-object.js][put-object]\n\n## Run Tests\n\nAll of the cliff tests are written in [vows][4], and cover all of the use cases described above.\n\n```\n  npm test\n```\n\n## Motivation\n\nCliff is the swiss army knife of CLI formatting tools. It is based on highly flexible and powerful libraries: \n\n* [winston][0]: A multi-transport async logging library for node.js\n* [eyes][1]: A customizable value inspector for node.js\n* [colors][2]: Get colors in your node.js console like what \n\n\n#### Author: [Charlie Robbins](http://twitter.com/indexzero)\n\n[0]: http://github.com/indexzero/winston\n[1]: http://github.com/cloudhead/eyes.js\n[2]: http://github.com/marak/colors.js\n[3]: http://github.com/flatiron/cliff/tree/master/examples\n[4]: http://vowsjs.org\n\n[inspect]: https://github.com/flatiron/cliff/raw/master/assets/inspect.png\n[put-object-rows]: https://github.com/flatiron/cliff/raw/master/assets/put-object-rows.png\n[put-object]: https://github.com/flatiron/cliff/raw/master/assets/put-object.png\n[put-rows-colors]: https://github.com/flatiron/cliff/raw/master/assets/put-rows-colors.png\n[put-rows]: https://github.com/flatiron/cliff/raw/master/assets/put-rows.png\n[string-object-rows]: https://github.com/flatiron/cliff/raw/master/assets/string-object-rows.png\n[string-rows]: https://github.com/flatiron/cliff/raw/master/assets/string-rows.png","publish_time":1307502826716,"maintainers":[{"name":"indexzero","email":"charlie.robbins@gmail.com"},{"name":"jcrugzz","email":"jcrugzz@gmail.com"}],"_cnpm_publish_time":1307502826716,"dist-tags":{"latest":"0.1.10"}}