From ec7b84191f539c1a3f890fc994dd62b68d3232fd Mon Sep 17 00:00:00 2001
From: Wietse Venema <356014+wietsevenema@users.noreply.github.com>
Date: Thu, 14 Aug 2025 20:08:59 +0200
Subject: feat: Allow combining -p and stdin for prompt input (#4406)

Co-authored-by: Allen Hutchison <adh@google.com>
---
 packages/cli/src/gemini.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'packages/cli/src/gemini.tsx')

diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx
index 54e58f72..565625d8 100644
--- a/packages/cli/src/gemini.tsx
+++ b/packages/cli/src/gemini.tsx
@@ -297,8 +297,11 @@ export async function main() {
   }
   // If not a TTY, read from stdin
   // This is for cases where the user pipes input directly into the command
-  if (!process.stdin.isTTY && !input) {
-    input += await readStdin();
+  if (!process.stdin.isTTY) {
+    const stdinData = await readStdin();
+    if (stdinData) {
+      input = `${stdinData}\n\n${input}`;
+    }
   }
   if (!input) {
     console.error('No input provided via stdin.');
-- 
cgit v1.2.3

