summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorEd Zynda <[email protected]>2025-05-23 14:54:09 +0300
committerGitHub <[email protected]>2025-05-23 06:54:09 -0500
commit89e3a72ae10b96cc1d8a01a8882c6d9e81f20b6a (patch)
tree1057cf90f0c55556de740fdb6798464e88732839 /README.md
parentb9ebcea82c262dc834633c2c8f44a94fe8773a15 (diff)
downloadopencode-89e3a72ae10b96cc1d8a01a8882c6d9e81f20b6a.tar.gz
opencode-89e3a72ae10b96cc1d8a01a8882c6d9e81f20b6a.zip
feat: add support for piped input to CLI (#51)
Diffstat (limited to 'README.md')
-rw-r--r--README.md15
1 files changed, 14 insertions, 1 deletions
diff --git a/README.md b/README.md
index b4ed0f7f0..c9ebb45e7 100644
--- a/README.md
+++ b/README.md
@@ -245,26 +245,39 @@ opencode -c /path/to/project
## Non-interactive Prompt Mode
-You can run OpenCode in non-interactive mode by passing a prompt directly as a command-line argument. This is useful for scripting, automation, or when you want a quick answer without launching the full TUI.
+You can run OpenCode in non-interactive mode by passing a prompt directly as a command-line argument or by piping text into the command. This is useful for scripting, automation, or when you want a quick answer without launching the full TUI.
```bash
# Run a single prompt and print the AI's response to the terminal
opencode -p "Explain the use of context in Go"
+# Pipe input to OpenCode (equivalent to using -p flag)
+echo "Explain the use of context in Go" | opencode
+
# Get response in JSON format
opencode -p "Explain the use of context in Go" -f json
+# Or with piped input
+echo "Explain the use of context in Go" | opencode -f json
# Run without showing the spinner
opencode -p "Explain the use of context in Go" -q
+# Or with piped input
+echo "Explain the use of context in Go" | opencode -q
# Enable verbose logging to stderr
opencode -p "Explain the use of context in Go" --verbose
+# Or with piped input
+echo "Explain the use of context in Go" | opencode --verbose
# Restrict the agent to only use specific tools
opencode -p "Explain the use of context in Go" --allowedTools=view,ls,glob
+# Or with piped input
+echo "Explain the use of context in Go" | opencode --allowedTools=view,ls,glob
# Prevent the agent from using specific tools
opencode -p "Explain the use of context in Go" --excludedTools=bash,edit
+# Or with piped input
+echo "Explain the use of context in Go" | opencode --excludedTools=bash,edit
```
In this mode, OpenCode will process your prompt, print the result to standard output, and then exit. All permissions are auto-approved for the session.