tender-cli
Version:
Command line interface for Tender
63 lines (50 loc) • 2.04 kB
JavaScript
// Generated by CoffeeScript 1.6.2
var ListReporter, Reporter, 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');
Reporter = require('../../reporter');
ListReporter = (function(_super) {
__extends(ListReporter, _super);
function ListReporter() {
this.format = __bind(this.format, this);
this.map = __bind(this.map, this); _ref = ListReporter.__super__.constructor.apply(this, arguments);
return _ref;
}
ListReporter.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();
};
ListReporter.prototype.format = function(callback) {
var i, _i, _len, _ref1;
if (!this.data) {
return callback();
}
this.output = "\nDisplaying (" + this.data.length + ") discussions: \n";
_ref1 = this.data;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
i = _ref1[_i];
this.output += "Discussion #" + i.id + "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nTitle : " + i.title + "\nState : " + i.state + "\nAuthor : " + i.author_name + "\nAge : " + i.age + "\n";
}
return callback();
};
return ListReporter;
})(Reporter);
module.exports = function(options, callback) {
return new ListReporter(options, callback);
};
module.exports.description = "Verbose vertical list";