UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

39 lines (38 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.create = void 0; const logger_1 = require("../../../logger"); const create = (command, errorMessage = "Command failed") => async (cCommand) => { const { output } = (0, logger_1.get)("handler.root"); const hdlr = await command.handler(cCommand); return async (...args) => { try { await hdlr(...args); } catch (err) { output(errorMessage); throw err; } finally { if (command.deprecationInfo?.deprecated) { let message = `WARNING: The command '${command.command}' is deprecated.`; if (command.deprecationInfo.deprecatedWithWave) { message = `WARNING: The command '${command.command}' is deprecated from version ` + `${command.deprecationInfo.deprecatedWithWave} onwards.`; } if (command.deprecationInfo.decommissionedAfterWave) { message += ` It will be removed after version ${command.deprecationInfo.decommissionedAfterWave}.`; } if (command.deprecationInfo.newCommand) { message += ` Please start using the new command '${command.deprecationInfo.newCommand}'.`; } if (command.deprecationInfo.sapHelpUrl) { message += ` See ${command.deprecationInfo.sapHelpUrl} for more information.`; } output(message); } } }; }; exports.create = create;