54 lines
6.7 KiB
JavaScript
54 lines
6.7 KiB
JavaScript
|
/// <reference path="./typings/main.d.ts" />
|
||
|
var plugins = require("./beautylog.plugins");
|
||
|
var tableHelpers = {
|
||
|
makeRow: function (cellCounterArg, colorArg) {
|
||
|
if (cellCounterArg === void 0) { cellCounterArg = 2; }
|
||
|
if (colorArg === void 0) { colorArg = "cyan"; }
|
||
|
var rowArray = [];
|
||
|
for (var i = 0; i < (cellCounterArg); i++) {
|
||
|
rowArray.push(String(i + 1).cyan);
|
||
|
}
|
||
|
return rowArray;
|
||
|
}
|
||
|
};
|
||
|
var ConsoleTable = (function () {
|
||
|
function ConsoleTable(tableTypeArg, tableHeadArrayArg) {
|
||
|
if (tableHeadArrayArg === void 0) { tableHeadArrayArg = tableHelpers.makeRow(); }
|
||
|
switch (tableTypeArg) {
|
||
|
case "checks":
|
||
|
this.tableHead = ['Check Item:'.cyan, 'Status:'.cyan];
|
||
|
break;
|
||
|
case "custom":
|
||
|
this.tableHead = tableHeadArrayArg;
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
this.rows = [];
|
||
|
this.type = tableTypeArg;
|
||
|
}
|
||
|
ConsoleTable.prototype.push = function (row) {
|
||
|
this.rows.push(row);
|
||
|
};
|
||
|
ConsoleTable.prototype.print = function () {
|
||
|
var table = new plugins.cliTable({
|
||
|
head: this.tableHead
|
||
|
});
|
||
|
for (var row in this.rows) {
|
||
|
if (this.rows[row][1] == "success") {
|
||
|
this.rows[row][1] = ' '.bgGreen + ' ' + this.rows[row][1];
|
||
|
}
|
||
|
else if (this.rows[row][1] == "error") {
|
||
|
this.rows[row][1] = ' '.bgRed + ' ' + this.rows[row][1];
|
||
|
}
|
||
|
table.push(this.rows[row]);
|
||
|
}
|
||
|
;
|
||
|
console.log(table.toString());
|
||
|
};
|
||
|
return ConsoleTable;
|
||
|
})();
|
||
|
exports.ConsoleTable = ConsoleTable;
|
||
|
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2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