1 | ;
|
2 | /*
|
3 | * Copyright © 2019 Atomist, Inc.
|
4 | *
|
5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | * you may not use this file except in compliance with the License.
|
7 | * You may obtain a copy of the License at
|
8 | *
|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 | *
|
11 | * Unless required by applicable law or agreed to in writing, software
|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | * See the License for the specific language governing permissions and
|
15 | * limitations under the License.
|
16 | */
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.createCommand = void 0;
|
19 | const onCommand_1 = require("@atomist/automation-client/lib/onCommand");
|
20 | const SmartParameters_1 = require("@atomist/automation-client/lib/SmartParameters");
|
21 | /**
|
22 | * Wrap a function in a command handler, allowing use of custom parameters.
|
23 | * Targeting (targets property) is handled automatically if the parameters
|
24 | * do not implement TargetsParams
|
25 | * @param sdm machine or options
|
26 | * @param commandMaker function to create command function
|
27 | * @param name command name
|
28 | * @param paramsMaker parameters factory, typically the name of a class with a no arg constructor
|
29 | * @param details optional details to customize behavior
|
30 | * Add intent "edit <name>"
|
31 | */
|
32 | function createCommand(sdm, commandMaker, name, paramsMaker = SmartParameters_1.NoParameters, details = {}) {
|
33 | const description = details.description || name;
|
34 | const detailsToUse = Object.assign({ description }, details);
|
35 | return onCommand_1.commandHandlerFrom(commandMaker(sdm), paramsMaker, name, detailsToUse.description, detailsToUse.intent, detailsToUse.tags, detailsToUse.autoSubmit, detailsToUse.parameterStyle);
|
36 | }
|
37 | exports.createCommand = createCommand;
|
38 | //# sourceMappingURL=createCommand.js.map |
\ | No newline at end of file |