ttrpg-tools/src/cli/index.ts

33 lines
998 B
TypeScript
Raw Normal View History

2026-02-26 00:17:23 +08:00
#!/usr/bin/env node
import { Command } from 'commander';
import { serveCommand } from './commands/serve.js';
import { compileCommand } from './commands/compile.js';
2026-03-17 20:01:04 +08:00
import { mcpCommand } from './commands/mcp.js';
2026-02-26 13:35:09 +08:00
import type { ServeOptions, CompileOptions } from './types.js';
2026-02-26 00:17:23 +08:00
const program = new Command();
program
.name('ttrpg')
.description('TTRPG 工具箱 - 用于编译和预览 TTRPG 文档')
.version('0.0.1');
program
.command('serve')
.description('运行一个 web 服务器预览目录中的内容,并实时监听更新')
.argument('[dir]', '要预览的目录', '.')
.option('-p, --port <port>', '端口号', '3000')
.action(serveCommand);
program
.command('compile')
.description('将目录中的内容输出为带 hash 路由、单个 html 入口的 web 应用')
.argument('[dir]', '要编译的目录', '.')
.option('-o, --output <dir>', '输出目录', './dist/output')
.action(compileCommand);
2026-03-17 20:01:04 +08:00
program
.addCommand(mcpCommand);
2026-02-26 00:17:23 +08:00
program.parse();