"use strict";
const fs = require("fs");
const path = require("path");
const util = require("util");
class Command {
    execute(args) {
        var topic = (args[0] || "").toLowerCase();
        if (topic === "help") {
            topic = "";
        }
        var helpContent = fs.readFileSync(path.join(__dirname, "../../resources/help.txt")).toString();
        var pattern = util.format("--\\[%s\\]--((.|[\\r\\n])+?)--\\[/\\]--", this.escape(topic));
        var regex = new RegExp(pattern);
        var match = regex.exec(helpContent);
        if (match) {
            var helpText = match[1].trim();
            console.log(helpText);
        }
    }
    escape(s) {
        return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
    }
}
exports.Command = Command;
