diff options
| author | Jaana Dogan <[email protected]> | 2025-04-18 19:26:16 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-18 19:26:16 -0700 |
| commit | 65e8e3ed1f759a273f2a8f667e8af4bbeeccaa36 (patch) | |
| tree | 7ca4716e60d68736020d8462c950a1fc48b8f1c8 /packages/cli/src | |
| parent | 4354458cadc74fe85f885374506dbde0f1924bc9 (diff) | |
Show error when GEMINI_API_KEY is not set (#52)
Also fix the bug where the API key is used accidentally as the model name.
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/config/config.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index 5c64e2ab..d9960613 100644 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -39,10 +39,17 @@ export class Config { export function loadConfig(): Config { loadEnvironment(); + if (!process.env.GEMINI_API_KEY) { + console.log( + 'GEMINI_API_KEY is not set. See https://ai.google.dev/gemini-api/docs/api-key to obtain one. ' + + 'Please set it in your .env file or as an environment variable.', + ); + process.exit(1); + } const argv = parseArguments(); return new Config( - process.env.GEMINI_API_KEY || '', - argv.model || process.env.GEMINI_API_KEY || DEFAULT_GEMINI_MODEL, + process.env.GEMINI_API_KEY, + argv.model || DEFAULT_GEMINI_MODEL, argv.target_dir || process.cwd(), ); } |
