@rawcmd/typewriters
Version:
Collection of typewriters for styling command-line messages for Rawcmd.
25 lines • 982 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@rawcmd/core");
const contents_1 = require("./contents");
const title_1 = require("./title");
function commandsTypewriter(options) {
options = Object.assign({ title: 'Commands' }, options);
const writeTitle = title_1.titleTypewriter(options);
const writeBody = contents_1.contentsTypewriter(options);
return (command) => {
if (!command || command.commands.length <= 0) {
return '';
}
const data = command.commands.filter((c) => {
return !!c.name && !!c.description;
}).map((c) => {
return [c.name, c.description];
});
const titleOutput = writeTitle(options.title);
const bodyOutput = writeBody(data);
return [titleOutput, bodyOutput].filter((o) => !!o).join(core_1.EOL);
};
}
exports.commandsTypewriter = commandsTypewriter;
//# sourceMappingURL=commands.js.map