UNPKG

tender-cli

Version:

Command line interface for Tender

69 lines (55 loc) 2.04 kB
// Generated by CoffeeScript 1.6.2 var Reporter, Table, TableReporter, moment, _ref, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; moment = require('moment'); Table = require('cli-table'); Reporter = require('../../reporter'); TableReporter = (function(_super) { __extends(TableReporter, _super); function TableReporter() { this.format = __bind(this.format, this); this.map = __bind(this.map, this); _ref = TableReporter.__super__.constructor.apply(this, arguments); return _ref; } TableReporter.prototype.map = function(callback) { var created, i, _i, _len, _ref1; this.data = []; _ref1 = this.options.data; for (_i = 0, _len = _ref1.length; _i < _len; _i++) { i = _ref1[_i]; created = moment(i.created_at); this.data.push({ id: i.id, title: i.title, author_name: i.author_name, state: i.state, age: created.fromNow(true) }); } return callback(); }; TableReporter.prototype.format = function(callback) { var i, table, _i, _len, _ref1; if (!this.data) { return callback(); } table = new Table({ head: ['Id', 'Title', 'Author', 'State', 'Age'], colWidths: [10, 45, 16, 10, 10] }); _ref1 = this.data; for (_i = 0, _len = _ref1.length; _i < _len; _i++) { i = _ref1[_i]; table.push([i.id, i.title, i.author_name, i.state, i.age]); } this.output = table.toString(); return callback(); }; return TableReporter; })(Reporter); module.exports = function(options, callback) { return new TableReporter(options, callback); }; module.exports.description = "Summary fields in table format";