"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const package_json_1 = __importDefault(require("../package.json"));
const index_1 = __importDefault(require("../commands/init/index"));
const publish_1 = __importDefault(require("../commands/publish"));
const preview_1 = __importDefault(require("../commands/preview"));
const generate_1 = __importDefault(require("../commands/generate"));
const build_1 = __importDefault(require("../commands/build"));
const translate_1 = __importDefault(require("../commands/translate"));
const i18n_replace_1 = __importDefault(require("../commands/i18n-replace"));
const oss_1 = __importDefault(require("../commands/oss"));
const git_1 = __importDefault(require("../commands/git"));
const program = new commander_1.Command();
// 注册命令
function registerCommand() {
    program
        .name(Object.keys(package_json_1.default.bin)[0]) // 主命令名称
        .usage('<command> [options]') // 规定用法规则
        .version(package_json_1.default.version); // 设置版本指令
    // 设置debug模式用于调试.默认隐藏选项
    program.addOption(new commander_1.Option('-d, --debug', '是否开启调试模式').default(false).hideHelp());
    // 注册:初始化模板指令
    // 初始化指令
    program.command('init').description('初始化模板项目').action(index_1.default);
    program
        .command('oss')
        .description('oss相关命令')
        .option('--ls,--list', '查看oss资源')
        .option('--upload', '上传文件到oss')
        .option('--doc', '上传文件到oss 目录Doc')
        .option('--ossPath <ossPath>', 'oss路径')
        .option('--localPath <localPath>', '本地上传文件目录')
        .option('--clear-cache', '清除缓存')
        .action(oss_1.default);
    // 生成指令
    program
        .command('generate')
        .description('生成物料')
        .option('--doc', '生成文档')
        .option('--clear-cache', '清除缓存')
        .action(generate_1.default);
    // 预览指令
    program
        .command('preview')
        .option('--doc', '预览文档')
        .description('预览物料')
        .action(preview_1.default);
    // 打包指令
    program
        .command('build')
        .option('--doc', '打包文档')
        .description('打包物料')
        .action(build_1.default);
    // 发布指令
    program
        .command('publish')
        .option('--doc', '发布文档')
        .description('发布物料')
        .action(publish_1.default);
    // 翻译文件命令
    program
        .command('fy')
        .option('--translate', '翻译文件')
        .option('--locale <localeto>', '翻译后的语言')
        .option('--localPath <localPath>', '本地上传文件目录')
        .option('--config <config>', '本地上传文件目录')
        .option('--outPutPath <outPutPath>', '本地输出文件目录')
        .description('翻译文件')
        .action(translate_1.default);
    // i18n语法替换
    program
        .command('replace')
        .description('自动用i18n替换中文')
        .action(i18n_replace_1.default);
    // git操作
    program
        .command('git')
        .option('--tag', '自动打标签')
        .description('git操作')
        .action(git_1.default);
    // 监听debug参数
    // 方便其他文件从process.env.debug中获取debug模式状态
    program.on('option:debug', function () {
        if (program.opts().debug) {
            process.env.debug = 'true';
        }
        else {
            process.env.debug = '';
        }
    });
    // 监听未知命令
    program.on('command:*', function (obj) {
        console.log(chalk_1.default.red(`${obj[0]} 是一个未知的命令！！！`));
        console.log(chalk_1.default.red(`---------- 请查阅下方使用文档：----------`));
        program.outputHelp();
    });
    // 处理指令参数
    program.parse(process.argv);
}
// module.exports = registerCommand
exports.default = registerCommand;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2NvcmUvY29tbWFuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHlDQUEyQztBQUMzQyxrREFBeUI7QUFDekIsbUVBQWlDO0FBQ2pDLG1FQUE2QztBQUM3QyxrRUFBNkM7QUFDN0Msa0VBQTZDO0FBQzdDLG9FQUErQztBQUMvQyw4REFBeUM7QUFDekMsc0VBQWdEO0FBQ2hELDRFQUFrRDtBQUNsRCwwREFBcUM7QUFDckMsMERBQXFDO0FBR3JDLE1BQU0sT0FBTyxHQUFHLElBQUksbUJBQU8sRUFBRSxDQUFBO0FBRTdCLE9BQU87QUFDUCxTQUFTLGVBQWU7SUFDdEIsT0FBTztTQUNKLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLHNCQUFHLENBQUMsR0FBRyx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