charlieanstey
2/16/2015 - 1:26 PM

Trello :: Export JSON to console using Node.js

Trello :: Export JSON to console using Node.js

'use strict';

var readline = require('readline');

// ------------------

function TrelloJsonExport() {}

TrelloJsonExport.prototype.outputComments = function(json) {
	json = JSON.parse(json);
	var comments = json.actions.filter(isCommentCard);
	comments.reverse();
	console.log('\nCOMMENTS START\n')
	for(var i = 0; i < comments.length; i++) {
		console.log(comments[i].data.text + '\n');
	}
	process.exit();
}

// Filter for comment cards
function isCommentCard(element, index, array) {
	return element.type == 'commentCard';
}

// ------------------

var rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});

var trello = new TrelloJsonExport();

rl.question('Enter Trello JSON:', trello.outputComments);