"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageManagerCommand = void 0;
const constants_1 = require("../../constants");
const yok_1 = require("../yok");
class PackageManagerCommand {
    constructor($userSettingsService, $errors, $logger, $stringParameter) {
        this.$userSettingsService = $userSettingsService;
        this.$errors = $errors;
        this.$logger = $logger;
        this.$stringParameter = $stringParameter;
        this.allowedParameters = [this.$stringParameter];
    }
    async execute(args) {
        const packageManagerName = args[0];
        const supportedPackageManagers = Object.keys(constants_1.PackageManagers);
        if (supportedPackageManagers.indexOf(packageManagerName) === -1) {
            this.$errors.fail(`${packageManagerName} is not a valid package manager. Supported values are: ${supportedPackageManagers.join(", ")}.`);
        }
        await this.$userSettingsService.saveSetting("packageManager", packageManagerName);
        this.$logger.printMarkdown(`Please ensure you have the directory containing \`${packageManagerName}\` executable available in your PATH.`);
        this.$logger.printMarkdown(`You've successfully set \`${packageManagerName}\` as your package manager.`);
    }
}
exports.PackageManagerCommand = PackageManagerCommand;
yok_1.injector.registerCommand("package-manager|set", PackageManagerCommand);
