Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Translate articles and documents between languages in three modes: quick, normal, and refined publication-quality.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/main.ts
1#!/usr/bin/env bun2import path from "node:path"3import process from "node:process"4import { runChunkCli } from "./chunk.js"56function formatScriptCommand(fallback: string): string {7const raw = process.argv[1]8const displayPath = raw9? (() => {10const relative = path.relative(process.cwd(), raw)11return relative && !relative.startsWith("..") ? relative : raw12})()13: fallback1415const quotedPath = displayPath.includes(" ")16? `"${displayPath.replace(/"/g, '\\"')}"`17: displayPath1819return `npx -y bun ${quotedPath}`20}2122function printUsage(exitCode: number): never {23const cmd = formatScriptCommand("scripts/main.ts")24console.log(`Baoyu Translate CLI2526Usage:27${cmd} <file> [--max-words 5000] [--output-dir <dir>]28${cmd} chunk <file> [--max-words 5000] [--output-dir <dir>]2930Commands:31chunk Split markdown into chunks3233Options:34--max-words <n> Maximum words per chunk (default: 5000)35--output-dir <dir> Write chunks into <dir>/chunks/36-h, --help Show help37`)38process.exit(exitCode)39}4041const args = process.argv.slice(2)4243if (args.length === 0) {44printUsage(1)45}4647if (args[0] === "-h" || args[0] === "--help") {48printUsage(0)49}5051if (args[0] === "chunk") {52process.exit(runChunkCli(args.slice(1), `${formatScriptCommand("scripts/main.ts")} chunk`))53}5455process.exit(runChunkCli(args, formatScriptCommand("scripts/main.ts")))56