lambdaorm-cli
Version:
The lambdaorm command line interface
48 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OutputService = void 0;
const json_light_1 = require("json-light");
const yaml = require('js-yaml');
class OutputService {
execute(result, type = 'json') {
try {
switch (type) {
case 'json':
console.log(JSON.stringify(result));
break;
case 'light':
console.log(json_light_1.JsonLight.compress(result));
break;
case 'beautiful':
console.log(JSON.stringify(result, null, 2));
break;
case 'yaml':
console.log(yaml.dump(result));
break;
default:
console.log(JSON.stringify(result));
break;
}
}
catch (error) {
console.error(`error: ${error}`);
}
}
showExecuteResult(results) {
if (!results || results.length === 0) {
console.log('No results');
}
else {
results.forEach((result) => {
if (result.error) {
console.error(`${result.description}: ${result.error.message}`);
}
else {
console.log(result.description);
}
});
}
}
}
exports.OutputService = OutputService;
//# sourceMappingURL=outputService.js.map