import AppConfig from '../../lib/appConfig.js';
import constants from '../constants.js';
import OutputManager from '../outputManager.js';
import RESTClient from '../restClient.js';
import TablePrinter from '../tablePrinter.js';
export default class TemplatesListDisplayer {
    async displayTemplates() {
        const appConfig = await AppConfig.getInstance();
        const response = await new RESTClient(new URL("templates.txt", appConfig.getConfig("listUrl", "templates") || constants.SCRIPT_TEMPLATES_BASE_URL).toString()).get();
        const templates = response.split("\n").filter((template) => template !== "")
            .map((template) => ({ name: template.trim() }));
        if (!templates || templates.length === 0) {
            OutputManager.info("No templates found.");
            return;
        }
        new TablePrinter('Templates', templates, [{ key: 'name', name: 'Name' }]).print();
    }
}
