@sap/cli-core
Version:
Command-Line Interface (CLI) Core Module
22 lines (21 loc) • 943 B
JavaScript
import { set as setConfig, get as getConfig } from "../../config/index.js";
import { OPTION_HOST, OPTION_OPTIONS_FILE, OPTION_VERBOSE, } from "../../constants.js";
import { getInfoFromTenant, parseTenant } from "../../utils/utils.js";
import { create as createNextHandler } from "./next.js";
import { create as createOptionsHandler } from "./options/index.js";
const MANDATORY_OPTIONS = [
OPTION_VERBOSE,
OPTION_OPTIONS_FILE,
{ ...OPTION_HOST, required: true },
];
const post = async () => async () => {
const config = getConfig();
const tenant = parseTenant(config.options[OPTION_HOST.longName]);
const info = getInfoFromTenant(tenant, config.verbose);
for (const [key, value] of Object.entries(info)) {
if (!config[key]) {
setConfig({ [key]: value });
}
}
};
export const create = () => createNextHandler("mandatoryOptions.handler", createOptionsHandler(MANDATORY_OPTIONS), post);