Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"permissions": {
"allow": [
"Bash(move:*)",
"Bash(mv:*)",
"Bash(node:*)"
],
"deny": [],
"ask": []
}
}
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,30 @@ node bin/cli.js

**Option A: Environment Variable (Recommended)**

Set it in your shell's configuration file (e.g., `.bashrc`, `.zshrc`):
```bash
export GEMINI_API_KEY="your-api-key-here"
```

**Option B: Command Line Argument**
**Option B: .env File (Local Setup)**

For local development, you can create a `.env` file by copying the provided example. This method is convenient and keeps your API key out of version control.

1. **Copy the example file:**
```bash
cp env.example .env
```

2. **Edit the `.env` file:**
Open the newly created `.env` file and replace the placeholder with your actual API key.
```dotenv
# .env
GEMINI_API_KEY="your-api-key-here"
```

**Option C: Command Line Argument**

Pass the key directly with the `--key` option. This method overrides environment variables and `.env` files.
```bash
md-translate translate -i file.md -l Spanish --key your-api-key-here
```
Expand Down
9 changes: 9 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#!/usr/bin/env node

import path from 'path';
import { fileURLToPath } from 'url';

import chalk from 'chalk';
import { Command } from 'commander';
import fs from 'fs-extra';
import ora from 'ora';
import dotenv from 'dotenv';

// Load environment variables from .env file
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const envPath = path.join(__dirname, '..', '.env');

// Try to load .env file, but don't fail if it doesn't exist
dotenv.config({ path: envPath });

import MarkdownTranslator from '../src/translator.js';

Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@playcanvas/eslint-config": "2.1.0",
"chalk": "^5.4.1",
"commander": "^14.0.0",
"dotenv": "^17.2.3",
"eslint": "^9.31.0",
"fs-extra": "^11.2.0",
"glob": "^11.0.3",
Expand Down