Skip to content

Commit 0dad053

Browse files
committed
feat: 添加版本号显示功能并更新版本信息
- 在 src/index.ts 中添加了显示版本号的功能 - 更新了 README-zh.md 和 README.md 中的版本信息 - 在 package.json 中更新了版本号至 1.0.5
1 parent 0d54769 commit 0dad053

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

README-zh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ npx ai-markdown-translator -i input.md -o output.md -l "Italian"
142142

143143
## 版本信息
144144

145-
- **当前版本**:1.0.4
145+
- **当前版本**:1.0.5
146146
- **NPM包**[ai-markdown-translator](https://www.npmjs.com/package/ai-markdown-translator)
147147

148148
## CI信息

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ npx ai-markdown-translator -i input.md -o output.md -l "Italian"
142142

143143
## Version Information
144144

145-
- **Current Version**: 1.0.4
145+
- **Current Version**: 1.0.5
146146
- **NPM Package**: [ai-markdown-translator](https://www.npmjs.com/package/ai-markdown-translator)
147147

148148
## CI Information

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ai-markdown-translator",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "CLI tool to translate Markdown files using OpenAI's language models while preserving the original formatting.",
55
"main": "dist/index.js",
66
"type": "module",

src/index.ts

+12
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,21 @@ async function main() {
256256
type: 'string',
257257
default: process.env.MODEL || 'gpt-4o-mini',
258258
})
259+
.option('version', {
260+
alias: 'v',
261+
description: '显示版本号',
262+
type: 'boolean',
263+
})
259264
.help()
260265
.alias('help', 'h').argv;
261266

267+
if (argv.version) {
268+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
269+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
270+
console.log(`版本号: ${packageJson.version}`);
271+
process.exit(0);
272+
}
273+
262274
try {
263275
if (!argv['openai-url']) {
264276
throw new Error('需要提供OpenAI URL。请通过--openai-url参数或OPENAI_URL环境变量提供。');

0 commit comments

Comments
 (0)