Skip to content

Commit

Permalink
feat: 添加版本号显示功能并更新版本信息
Browse files Browse the repository at this point in the history
- 在 src/index.ts 中添加了显示版本号的功能
- 更新了 README-zh.md 和 README.md 中的版本信息
- 在 package.json 中更新了版本号至 1.0.5
  • Loading branch information
h7ml committed Dec 11, 2024
1 parent 0d54769 commit 0dad053
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ npx ai-markdown-translator -i input.md -o output.md -l "Italian"

## 版本信息

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

## CI信息
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ npx ai-markdown-translator -i input.md -o output.md -l "Italian"

## Version Information

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

## CI Information
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ai-markdown-translator",
"version": "1.0.4",
"version": "1.0.5",
"description": "CLI tool to translate Markdown files using OpenAI's language models while preserving the original formatting.",
"main": "dist/index.js",
"type": "module",
Expand Down
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,21 @@ async function main() {
type: 'string',
default: process.env.MODEL || 'gpt-4o-mini',
})
.option('version', {
alias: 'v',
description: '显示版本号',
type: 'boolean',
})
.help()
.alias('help', 'h').argv;

if (argv.version) {
const packageJsonPath = path.join(__dirname, '..', 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
console.log(`版本号: ${packageJson.version}`);
process.exit(0);
}

try {
if (!argv['openai-url']) {
throw new Error('需要提供OpenAI URL。请通过--openai-url参数或OPENAI_URL环境变量提供。');
Expand Down

0 comments on commit 0dad053

Please sign in to comment.