2016-05-13 23:18:44 +00:00
|
|
|
"use strict";
|
2016-05-23 07:10:30 +00:00
|
|
|
require("typings-global");
|
2016-07-23 17:47:23 +00:00
|
|
|
const plugins = require("./beautylog.plugins");
|
|
|
|
let tableHelpers = {
|
|
|
|
makeRow: function (cellCounterArg = 2, colorArg = "cyan") {
|
|
|
|
let rowArray = [];
|
|
|
|
for (let i = 0; i < (cellCounterArg); i++) {
|
2016-05-13 23:18:44 +00:00
|
|
|
rowArray.push(String(i + 1).cyan);
|
|
|
|
}
|
|
|
|
return rowArray;
|
|
|
|
}
|
|
|
|
};
|
2016-07-23 17:47:23 +00:00
|
|
|
class Table {
|
|
|
|
constructor(tableTypeArg, tableHeadArrayArg = tableHelpers.makeRow()) {
|
2016-05-13 23:18:44 +00:00
|
|
|
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;
|
|
|
|
}
|
2016-07-23 17:47:23 +00:00
|
|
|
push(row) {
|
2016-05-13 23:18:44 +00:00
|
|
|
this.rows.push(row);
|
2016-07-23 17:47:23 +00:00
|
|
|
}
|
|
|
|
print() {
|
|
|
|
let table = new plugins.cliTable({
|
2016-05-13 23:18:44 +00:00
|
|
|
head: this.tableHead
|
|
|
|
});
|
2016-07-23 17:47:23 +00:00
|
|
|
for (let row in this.rows) {
|
2016-05-13 23:18:44 +00:00
|
|
|
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());
|
2016-07-23 17:47:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-13 23:18:44 +00:00
|
|
|
exports.Table = Table;
|
2016-07-23 17:47:23 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNsYXNzZXMudGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlsb2cuY2xhc3Nlcy50YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFFL0MsSUFBSSxZQUFZLEdBQUc7SUFDZixPQUFPLEVBQUUsVUFBUyxjQUFjLEdBQVUsQ0FBQyxFQUFDLFFBQVEsR0FBVSxNQUFNO1FBQ2hFLElBQUksUUFBUSxHQUFHLEVBQUUsQ0FBQztRQUNsQixHQUFHLENBQUMsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLEVBQUUsQ0FBQztZQUN4QyxRQUFRLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDdEMsQ0FBQztRQUNELE1BQU0sQ0FBQyxRQUFRLENBQUM7SUFDcEIsQ0FBQztDQUNKLENBQUM7QUFFRjtJQUlJLFlBQVksWUFBbUIsRUFBQyxpQkFBaUIsR0FBWSxZQUFZLENBQUMsT0FBTyxFQUFFO1FBQy9FLE1BQU0sQ0FBQyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7WUFDbkIsS0FBSyxRQUFRO2dCQUNULElBQUksQ0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