ask-cli-x
Version:
Alexa Skills Kit (ASK) Command Line Interfaces
41 lines (40 loc) • 1.81 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InteractiveMode = void 0;
const chalk_1 = __importDefault(require("chalk"));
const dialog_repl_view_1 = require("../../view/dialog-repl-view");
const dialog_controller_1 = require("../../controllers/dialog-controller");
const SPECIAL_COMMANDS_HEADER = 'Use ".record <fileName>" or ".record <fileName> --append-quit" to save list of utterances to a file.\n' +
'You can exit the interactive mode by entering ".quit" or "ctrl + c".';
class InteractiveMode extends dialog_controller_1.DialogController {
constructor(config) {
super(config);
this.header =
config.header ||
"Welcome to ASK Dialog\n" +
"In interactive mode, type your utterance text onto the console and hit enter\n" +
"Alexa will then evaluate your input and give a response!\n";
}
async start() {
try {
const interactiveReplView = new dialog_repl_view_1.DialogReplView({
prompt: chalk_1.default.yellow.bold("User > "),
header: this.header + SPECIAL_COMMANDS_HEADER,
footer: "Goodbye!",
evalFunc: (input, replCallback) => {
this.evaluateUtterance(input, interactiveReplView)
.then((x) => replCallback(null, x))
.catch((x) => replCallback(x, null));
},
});
await this.setupSpecialCommands(interactiveReplView);
}
catch (error) {
throw error;
}
}
}
exports.InteractiveMode = InteractiveMode;