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MAAM,EAAM,EAAe,UAAW,EAAe,SAM3E,GALA,EAAe,KAAO,EAAO,KAC7B,EAAe,KAAO,EAAO,KAIzB,EAAe,KAAK,UACpB,OAAO,KAAK,YAAY,KAAK,QAAS,GAK1C,SAAS,iBAAiB,EAAe,MAIzC,EAAe,QACnB,CACA,MAAO,GACH,OAAI,aAAiB,MACV,QAAQ,MAAM,MAAM,IAAI,WAAW,EAAM,YAE7C,QAAQ,MAAM,EACzB,CACJ","file":"/npm/@point-hub/express-cli@0.2.2/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@point-hub/express-cli@0.2.2/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { createRequire } from \"module\";\nimport { Argument } from \"./argument.js\";\nimport { BaseCommand } from \"./base-command.js\";\nimport { Color } from \"./color.js\";\nimport { Command } from \"./command.js\";\nimport { Help } from \"./help.js\";\nimport { Option } from \"./option.js\";\nexport { Prompt } from \"./prompt.js\";\nexport { Color } from \"./color.js\";\nexport { Table, DefaultTable } from \"./table.js\";\nexport { Argument, BaseCommand, Command, Help, Option };\nexport class ExpressCli {\n    constructor(name, version) {\n        if (version) {\n            this.version = version;\n        }\n        else {\n            this.version = this.packageVersion();\n        }\n        this.command = new Command(name);\n    }\n    /**\n     * Set cli version from package.json version\n     */\n    packageVersion() {\n        const require = createRequire(import.meta.url);\n        const { version } = require(\"../package.json\");\n        return version;\n    }\n    /**\n     * Register commands\n     */\n    register(cmd) {\n        this.command.createCommand(cmd);\n    }\n    /**\n     * Run CLI application\n     */\n    run(args) {\n        try {\n            /**\n             * Check duplicate commands, arguments, and options\n             */\n            const duplicate = this.command.findDuplicate();\n            if (duplicate.isDuplicate) {\n                if (duplicate.commands.length) {\n                    console.error(Color.red(\"[ERROR] Duplicate commands\"));\n                    console.error(duplicate.commands);\n                }\n                if (duplicate.arguments.length) {\n                    console.error(Color.red(\"[ERROR] Duplicate arguments\"));\n                    console.error(duplicate.arguments);\n                }\n                if (duplicate.options.length) {\n                    console.error(Color.red(\"[ERROR] Duplicate options\"));\n                    console.error(duplicate.options);\n                }\n                return;\n            }\n            /**\n             * Return root help if don't have any arguments / options\n             */\n            const argumentList = Argument.list(args);\n            if (argumentList.length === 0) {\n                const options = [\n                    {\n                        type: \"boolean\",\n                        flag: \"--version\",\n                        shorthand: \"-v\",\n                        description: \"Display version\",\n                    },\n                    {\n                        type: \"boolean\",\n                        flag: \"--help\",\n                        shorthand: \"-h\",\n                        description: \"Display help\",\n                    },\n                ];\n                const flags = Option.parseRoot(args, options);\n                if (flags[\"--version\"]) {\n                    return console.log(this.version);\n                }\n                return Help.rootHelp(this.command, options);\n            }\n            /**\n             * Check if command available\n             */\n            let currentCommand = this.command.getCommand(args[2]);\n            if (!currentCommand) {\n                currentCommand = this.command.getCommand(\"\");\n            }\n            if (!currentCommand) {\n                throw new Error(\"Command not found\");\n            }\n            /**\n             * Parse options and arguments from console into object\n             */\n            const parsed = Option.parse(args, currentCommand.arguments, currentCommand.options);\n            currentCommand.args = parsed.args;\n            currentCommand.opts = parsed.opts;\n            /**\n             * If help flag is found, show help instead\n             */\n            if (currentCommand.opts[\"--help\"]) {\n                return Help.commandHelp(this.command, currentCommand);\n            }\n            /**\n             * Argument should not undefined\n             */\n            Argument.requireArguments(currentCommand.args);\n            /**\n             * Handle command\n             */\n            currentCommand.handle();\n        }\n        catch (error) {\n            if (error instanceof Error) {\n                return console.error(Color.red(`[ERROR] ${error.message}`));\n            }\n            return console.error(error);\n        }\n    }\n}\n"]}