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 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-07 20:35:06 -05:00
parent df903379fe
commit 25e74054c8

View file

@ -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 <prompt> [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}"