"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**
 * Copyright 2017-2018 Plexus Interop Deutsche Bank AG
 * SPDX-License-Identifier: Apache-2.0
 *
 * 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.
 */
var DefaultOptions_1 = require("./DefaultOptions");
var java_1 = require("../common/java");
var BaseCommand_1 = require("./BaseCommand");
var process_1 = require("../common/process");
var protoc_1 = require("../common/protoc");
var GenCSharpCommand = /** @class */ (function (_super) {
    tslib_1.__extends(GenCSharpCommand, _super);
    function GenCSharpCommand() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.clientGenArgs = function (opts) {
            return ['--type=csharp'].concat(_this.optionArgs(opts));
        };
        _this.name = function () { return 'gen-csharp'; };
        _this.generalDescription = function () { return 'generate C# client and messages definitions for specified entry point'; };
        _this.options = function () { return [DefaultOptions_1.baseDir(), DefaultOptions_1.out('Generated'), DefaultOptions_1.plexusEntryPoint(), DefaultOptions_1.namespace('Plexus.Interop.Testing.Generated'), DefaultOptions_1.verbose()]; };
        return _this;
    }
    GenCSharpCommand.prototype.action = function (opts) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var javaExecPath, protocExecPath, javaLibPath;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        this.log('Generating interop client');
                        return [4 /*yield*/, java_1.getJavaExecPath()];
                    case 1:
                        javaExecPath = _a.sent();
                        protocExecPath = protoc_1.getProtocExecPath();
                        javaLibPath = java_1.getJavaGenLibPath();
                        return [4 /*yield*/, process_1.simpleSpawn(javaExecPath, ['-jar', javaLibPath].concat(this.clientGenArgs(opts), ["--protoc=" + protocExecPath]), this.isVerbose(opts))];
                    case 2:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    return GenCSharpCommand;
}(BaseCommand_1.BaseCommand));
exports.GenCSharpCommand = GenCSharpCommand;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR2VuQ1NoYXJwQ29tbWFuZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9HZW5DU2hhcnBDb21tYW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRztBQUNILG1EQUFzRjtBQUV0Rix1Q0FBb0U7QUFDcEUsNkNBQTRDO0FBQzVDLDZDQUFnRDtBQUNoRCwyQ0FBcUQ7QUFFckQ7SUFBc0MsNENBQVc7SUFBakQ7UUFBQSxxRUFzQkM7UUFwQlUsbUJBQWEsR0FBNEIsVUFBQSxJQUFJO1lBQ2hELFFBQVEsZUFBZSxTQUFLLEtBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLEVBQUU7UUFDdkQsQ0FBQyxDQUFBO1FBRU0sVUFBSSxHQUFHLGNBQU0sT0FBQSxZQUFZLEVBQVosQ0FBWSxDQUFDO1FBRTFCLHdCQUFrQixHQUFHLGNBQU0sT0FBQSx1RUFBdUUsRUFBdkUsQ0FBdUUsQ0FBQztRQUVuRyxhQUFPLEdBQW1CLGNBQU0sT0FBQSxDQUFDLHdCQUFPLEVBQUUsRUFBRSxvQkFBRyxDQUFDLFdBQVcsQ0FBQyxFQUFFLGlDQUFnQixFQUFFLEVBQUUsMEJBQVMsQ0FBQyxrQ0FBa0MsQ0FBQyxFQUFFLHdCQUFPLEVBQUUsQ0FBQyxFQUEzRyxDQUEyRyxDQUFDOztJQVl2SixDQUFDO0lBVmdCLGlDQUFNLEdBQW5CLFVBQW9CLElBQVM7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