From 25e74054c8750aef4e2865662c334ba80e389788 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 7 Mar 2026 20:35:06 -0500 Subject: [PATCH] Support --help and -h flags in imagegen tool Move API key check after argument parsing so help works without GEMINI_API_KEY set. Co-Authored-By: Claude Opus 4.6 --- tools/imagegen | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/imagegen b/tools/imagegen index 5232db519..aa7da7c89 100755 --- a/tools/imagegen +++ b/tools/imagegen @@ -10,11 +10,6 @@ if [[ -f "$REPO_ROOT/.env" ]]; then source "$REPO_ROOT/.env" fi -if [[ -z "${GEMINI_API_KEY:-}" ]]; then - echo "Error: GEMINI_API_KEY not set" >&2 - exit 1 -fi - usage() { echo "Usage: imagegen [output.png]" >&2 echo "" >&2 @@ -23,10 +18,15 @@ usage() { exit 1 } -if [[ $# -lt 1 ]]; then +if [[ $# -lt 1 ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then usage fi +if [[ -z "${GEMINI_API_KEY:-}" ]]; then + echo "Error: GEMINI_API_KEY not set" >&2 + exit 1 +fi + PROMPT="$1" OUTPUT="${2:-output.png}" MODEL="${IMAGEGEN_MODEL:-gemini-2.5-flash-image}"