alwaysai
Version:
The alwaysAI command-line interface (CLI)
32 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.promptForInput = void 0;
const prompts = require("prompts");
const alwayscli_1 = require("@alwaysai/alwayscli");
function getNonInteractiveStreamName() {
for (const streamName of ['stdin', 'stdout']) {
if (!process[streamName].isTTY) {
return streamName;
}
}
return undefined;
}
async function promptForInput(props) {
const { questions, purpose, alternative = 'use the --yes flag to disable interactive prompts' } = props;
const streamName = getNonInteractiveStreamName();
if (streamName) {
throw new alwayscli_1.CliTerseError(`We were about to prompt you ${purpose}, but standard ${streamName === 'stdin' ? 'input' : 'output'} (${streamName}) is not a TTY. Please re-run this command in a fully interactive terminal, or ${alternative}.`);
}
let canceled = false;
const answers = await prompts(questions, {
onCancel() {
canceled = true;
}
});
if (canceled) {
throw new alwayscli_1.CliTerseError('Operation canceled by user');
}
return answers;
}
exports.promptForInput = promptForInput;
//# sourceMappingURL=prompt-for-input.js.map