#!/usr/bin/env node import 'dotenv/config' import { analyzeWithGemini } from './gemini-analyzer' import * as fs from 'fs' import * as path from 'path' import { stdout } from 'process' async function main() { const args = process.argv.slice(2) const filePath = args[0] const modelFlag = args.find((arg) => arg.startsWith('--model=')) const apiKeyFlag = args.find((arg) => arg.startsWith('--api-key=')) const model = modelFlag ? modelFlag.split('=')[1] : 'gemini-2.0-flash' const apiKey = apiKeyFlag ? apiKeyFlag.split('=')[1] : process.env.GOOGLE_API_KEY if (!filePath) { console.error('Error: Please provide a file path') console.error('Usage: describe [--model=] [--api-key=]') process.exit(1) } if (!apiKey) { console.error('Error: No API key provided. Either:') console.error('1. Set the GOOGLE_API_KEY environment variable, or') console.error('2. Pass the API key with --api-key=') process.exit(1) } const resolvedPath = path.resolve(filePath) if (!fs.existsSync(resolvedPath)) { console.error(`Error: File '${resolvedPath}' not found`) process.exit(1) } try { const description = await analyzeWithGemini(resolvedPath, model, apiKey) // return the result using stdio stdout.write(description) } catch (err: any) { console.error('Error:', err.message || String(err)) process.exit(1) } } main().catch((err) => { console.error('Error:', err) process.exit(1) })