Commit 4570261
authored
Add --payload-file flag to kernel invoke (#66)
## Summary
Add a `--payload-file` / `-f` flag to `kernel invoke` that allows
reading the JSON payload from a file instead of passing it inline. This
is useful for:
- Large payloads that are unwieldy on the command line
- Payloads with special characters that need escaping
- Scripting and automation workflows
- Piping data from other commands
## Usage
```bash
# Read payload from a file
kernel invoke myapp action -f payload.json
# Read payload from stdin
cat payload.json | kernel invoke myapp action -f -
# Pipe from another command
echo '{"key": "value"}' | kernel invoke myapp action -f -
# Combine with other tools
jq '.data' response.json | kernel invoke myapp process -f -
```
## Details
- The `--payload` and `--payload-file` flags are mutually exclusive
(enforced by cobra)
- Supports `-` as a special filename to read from stdin
- Validates that the file contents are valid JSON before invoking
- Trims whitespace from file contents
## Test plan
- [x] `go build ./...` passes
- [x] `go test ./...` passes
- [x] Help output shows new flag correctly
- [ ] Manual test: `kernel invoke app action -f payload.json`
- [ ] Manual test: `echo '{}' | kernel invoke app action -f -`
- [ ] Manual test: verify `--payload` and `--payload-file` cannot be
used together
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds file/stdin-based payload input to `kernel invoke` with JSON
validation and updates docs.
>
> - Introduces `--payload-file`, `-f` flag in `invoke` (mutually
exclusive with `--payload`)
> - New `getPayload` helper supports reading from file or `-` (stdin),
trims whitespace, and validates JSON before invoking
> - Wires payload into invocation params when provided; preserves
existing sync/async behavior
> - README updated with new flag in command reference and examples for
file/stdin/pipe usage
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d7205d5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 54b919a commit 4570261
2 files changed
Lines changed: 70 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
423 | 424 | | |
424 | 425 | | |
425 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
426 | 436 | | |
427 | 437 | | |
428 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
40 | 42 | | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
| |||
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
221 | 272 | | |
222 | 273 | | |
223 | 274 | | |
| |||
0 commit comments