UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

38 lines 1.88 kB
"use strict"; /* * Copyright © 2019 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createCommand = void 0; const onCommand_1 = require("@atomist/automation-client/lib/onCommand"); const SmartParameters_1 = require("@atomist/automation-client/lib/SmartParameters"); /** * Wrap a function in a command handler, allowing use of custom parameters. * Targeting (targets property) is handled automatically if the parameters * do not implement TargetsParams * @param sdm machine or options * @param commandMaker function to create command function * @param name command name * @param paramsMaker parameters factory, typically the name of a class with a no arg constructor * @param details optional details to customize behavior * Add intent "edit <name>" */ function createCommand(sdm, commandMaker, name, paramsMaker = SmartParameters_1.NoParameters, details = {}) { const description = details.description || name; const detailsToUse = Object.assign({ description }, details); return onCommand_1.commandHandlerFrom(commandMaker(sdm), paramsMaker, name, detailsToUse.description, detailsToUse.intent, detailsToUse.tags, detailsToUse.autoSubmit, detailsToUse.parameterStyle); } exports.createCommand = createCommand; //# sourceMappingURL=createCommand.js.map