import { UtilsTerminal } from 'tnp-core/lib';
import { chalk } from 'tnp-core/lib';
import { HelpersTaon, UtilsVSCode, } from 'tnp-helpers/lib';
import { BaseCli } from './base-cli';
//#endregion
export class $Vscode extends BaseCli {
    async _() {
        this._displayMenu();
    }
    //#region display menu
    async _displayMenu() {
        //#region @backendFunc
        try {
            while (true) {
                UtilsTerminal.clearConsole();
                const items = {
                    firstLine: {
                        name: chalk.gray.bold('Please select Up/Down action or CTRL+C to exit'),
                    },
                    global: {
                        name: 'Apply global settings',
                        action: async () => {
                            await UtilsVSCode.applyProperGlobalSettings();
                            await UtilsTerminal.pressAnyKeyToContinueAsync();
                        },
                    },
                    listInstalledExtensions: {
                        name: 'List installed extensions',
                        action: async () => {
                            UtilsTerminal.clearConsole();
                            await UtilsTerminal.previewLongList(UtilsVSCode.installedExtensions().map((c, index) => `${index + 1}. ${c}`), 'List of installed extensions');
                            // UtilsTerminal.pressAnyKey();
                        },
                    },
                    installExtensions: {
                        name: 'Install all recommended extensions',
                        action: async () => {
                            // UtilsTerminal.clearConsole();
                            await UtilsVSCode.installExtensions();
                        },
                    },
                    installUninstallExtensions: {
                        name: 'Install all recommended and uninstall deprecated extensions',
                        action: async () => {
                            // UtilsTerminal.clearConsole();
                            await UtilsVSCode.installAndRemoveDeprecatedExtensions();
                        },
                    },
                    removeDeprecated: {
                        name: 'Uninstall deprecated extensions',
                        action: async () => {
                            // UtilsTerminal.clearConsole();
                            await UtilsVSCode.removeDeprecated();
                        },
                    },
                    initLocalSettings: {
                        name: 'Init local settings',
                        action: async () => {
                            await this._init();
                        },
                    },
                };
                if (!this.project) {
                    delete items.initLocalSettings;
                }
                await UtilsTerminal.selectActionAndExecute(items, {
                    autocomplete: false,
                });
                // lastAction = res.selected !== 'firstLine';
            }
        }
        catch (error) {
            error && console.error('error', error);
            this._exit();
        }
        //#endregion
    }
    //#endregion
    //#region global
    GLOBAL() {
        UtilsVSCode.applyProperGlobalSettings();
        this._exit();
    }
    //#endregion
    TEMP_SHOW() {
        if (!this.project) {
            return;
        }
        this._showfilesfor(this.project.ins.Current);
        this._exit();
    }
    TEMP_HIDE() {
        if (!this.project) {
            return;
        }
        this._hidefilesfor(this.project);
        this._exit();
    }
    _init() {
        this.project.vsCodeHelpers.toogleFilesVisibilityInVscode({
            action: 'hide-files',
        });
    }
    INIT() {
        if (!this.project) {
            return;
        }
        this._init();
        this._exit();
    }
    _showfilesfor(project) {
        project.vsCodeHelpers.toogleFilesVisibilityInVscode({
            action: 'show-files',
        });
    }
    _hidefilesfor(project) {
        project.vsCodeHelpers.toogleFilesVisibilityInVscode({
            action: 'hide-files',
        });
    }
}
export default {
    $Vscode: HelpersTaon.CLIWRAP($Vscode, '$Vscode'),
};
//# sourceMappingURL=cli-VSCODE.js.map