@sap/cli-core
Version:
Command-Line Interface (CLI) Core Module
21 lines (20 loc) • 845 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
const logger_1 = require("../../../logger");
const utils_1 = require("./utils");
const create = (option, promptAlways = false) => async () => async () => {
const { debug } = (0, logger_1.get)("commands.handler.options.option");
debug(`reading option ${option.longName} from options`);
if (option.required || promptAlways) {
if (!option.prompts) {
throw new Error(`inconsistent option ${option.longName}, no prompts configuration available`);
}
const value = await (0, utils_1.promptForValue)(option);
(0, utils_1.setOption)(option, value);
}
else {
throw new Error(`option ${option.longName} is not required and promptAlways is false`);
}
};
exports.create = create;