"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoCompleteStatusCommand = exports.EnableAutoCompleteCommand = exports.DisableAutoCompleteCommand = exports.AutoCompleteCommand = void 0;
const helpers = require("../helpers");
const yok_1 = require("../yok");
class AutoCompleteCommand {
    constructor($autoCompletionService, $logger, $prompter) {
        this.$autoCompletionService = $autoCompletionService;
        this.$logger = $logger;
        this.$prompter = $prompter;
        this.disableAnalytics = true;
        this.allowedParameters = [];
    }
    async execute(args) {
        if (helpers.isInteractive()) {
            if (this.$autoCompletionService.isAutoCompletionEnabled()) {
                if (this.$autoCompletionService.isObsoleteAutoCompletionEnabled()) {
                    await this.$autoCompletionService.enableAutoCompletion();
                }
                else {
                    this.$logger.info("Autocompletion is already enabled");
                }
            }
            else {
                this.$logger.info("If you are using bash or zsh, you can enable command-line completion.");
                const message = "Do you want to enable it now?";
                const autoCompetionStatus = await this.$prompter.confirm(message, () => true);
                if (autoCompetionStatus) {
                    await this.$autoCompletionService.enableAutoCompletion();
                }
                else {
                    this.$autoCompletionService.disableAutoCompletion();
                }
            }
        }
    }
}
exports.AutoCompleteCommand = AutoCompleteCommand;
yok_1.injector.registerCommand("autocomplete|*default", AutoCompleteCommand);
class DisableAutoCompleteCommand {
    constructor($autoCompletionService, $logger) {
        this.$autoCompletionService = $autoCompletionService;
        this.$logger = $logger;
        this.disableAnalytics = true;
        this.allowedParameters = [];
    }
    async execute(args) {
        if (this.$autoCompletionService.isAutoCompletionEnabled()) {
            this.$autoCompletionService.disableAutoCompletion();
        }
        else {
            this.$logger.info("Autocompletion is already disabled.");
        }
    }
}
exports.DisableAutoCompleteCommand = DisableAutoCompleteCommand;
yok_1.injector.registerCommand("autocomplete|disable", DisableAutoCompleteCommand);
class EnableAutoCompleteCommand {
    constructor($autoCompletionService, $logger) {
        this.$autoCompletionService = $autoCompletionService;
        this.$logger = $logger;
        this.disableAnalytics = true;
        this.allowedParameters = [];
    }
    async execute(args) {
        if (this.$autoCompletionService.isAutoCompletionEnabled()) {
            this.$logger.info("Autocompletion is already enabled.");
        }
        else {
            await this.$autoCompletionService.enableAutoCompletion();
        }
    }
}
exports.EnableAutoCompleteCommand = EnableAutoCompleteCommand;
yok_1.injector.registerCommand("autocomplete|enable", EnableAutoCompleteCommand);
class AutoCompleteStatusCommand {
    constructor($autoCompletionService, $logger) {
        this.$autoCompletionService = $autoCompletionService;
        this.$logger = $logger;
        this.disableAnalytics = true;
        this.allowedParameters = [];
    }
    async execute(args) {
        if (this.$autoCompletionService.isAutoCompletionEnabled()) {
            this.$logger.info("Autocompletion is enabled.");
        }
        else {
            this.$logger.info("Autocompletion is disabled.");
        }
    }
}
exports.AutoCompleteStatusCommand = AutoCompleteStatusCommand;
yok_1.injector.registerCommand("autocomplete|status", AutoCompleteStatusCommand);
