"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateLinksCommandLineParser = void 0;
const ts_command_line_1 = require("@rushstack/ts-command-line");
const node_core_library_1 = require("@rushstack/node-core-library");
const CreateLinksAction_1 = require("./actions/CreateLinksAction");
const RemoveLinksAction_1 = require("./actions/RemoveLinksAction");
class CreateLinksCommandLineParser extends ts_command_line_1.CommandLineParser {
    constructor(terminal) {
        super({
            toolFilename: 'create-links',
            toolDescription: 'Create or remove symlinks for the extracted packages'
        });
        this._terminal = terminal;
        this.addAction(new CreateLinksAction_1.CreateLinksAction(this._terminal));
        this.addAction(new RemoveLinksAction_1.RemoveLinksAction(this._terminal));
    }
    async onExecuteAsync() {
        process.exitCode = 1;
        try {
            await super.onExecuteAsync();
            process.exitCode = 0;
        }
        catch (error) {
            if (!(error instanceof node_core_library_1.AlreadyReportedError)) {
                this._terminal.writeErrorLine();
                this._terminal.writeErrorLine('ERROR: ' + error.message.trim());
            }
        }
    }
}
exports.CreateLinksCommandLineParser = CreateLinksCommandLineParser;
//# sourceMappingURL=CreateLinksCommandLineParser.js.map