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