ask-cli-x
Version:
Alexa Skills Kit (ASK) Command Line Interfaces
38 lines (37 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DialogReplView = void 0;
const cli_repl_view_1 = require("./cli-repl-view");
class DialogReplView extends cli_repl_view_1.CliReplView {
/**
* Constructor for DialogReplView.
* @param {Object} configuration config object.
*/
constructor(configuration) {
const conf = configuration || {};
conf.prettifyHeaderFooter = (arg) => {
const lines = arg.split("\n");
const terminalWidth = process.stdout.columns;
const halfWidth = Math.floor(terminalWidth / 2);
const bar = "=".repeat(terminalWidth);
const formattedLines = lines.map((line) => {
const paddedLine = ` ${line.trim()} `;
const offset = halfWidth - Math.floor(paddedLine.length / 2);
if (offset < 0) {
return `===${paddedLine}===`;
}
return bar.slice(0, offset) + paddedLine + bar.slice(offset + paddedLine.length);
});
return `\n${formattedLines.join("\n")}\n`;
};
super(conf);
}
/**
* Specify the record special command.
* @param {Function} func What function to execute when .record command is inputted.
*/
registerRecordCommand(func) {
this.registerSpecialCommand("record", "Record input utterances to a replay file of a specified name.", func);
}
}
exports.DialogReplView = DialogReplView;