-
Notifications
You must be signed in to change notification settings - Fork 23
feat(cli): add pipe support to stop, start, delete, and ls commands #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add stdin piping and improved output for CLI composability.
Stop/Start/Delete:
- Accept instance names from stdin (one per line)
- Accept multiple instance names as arguments
- Output instance names when piped for chaining
- Add --all flag to stop command
Ls improvements:
- Add --json flag for JSON output
- Output plain table when piped (for grep/awk)
- Add JSON and pipe support to ls orgs
Examples:
brev ls | awk '/RUNNING/ {print $1}' | brev stop
brev ls | grep "test-" | awk '{print $1}' | brev delete
brev ls --json | jq '.[] | select(.status == "RUNNING")'
brev stop --all
- Extract trackLsAnalytics() in ls.go - Extract runBatchStart() and runSingleStart() in start.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Manual QA Results ✅Build & Static Analysis:
Test Plan Verification:
Piping Integration Test:
Notes:
|
- Consolidate duplicate isStdoutPiped() from delete, ls, start, stop - Consolidate duplicate getInstanceNames() from delete, stop - Consolidate duplicate getInstanceNamesFromStdin() from start - Create IsStdoutPiped(), IsStdinPiped(), GetInstanceNames(), GetInstanceNamesWithPipeInfo() - Remove ~108 lines of duplicated code
ea4dba8 to
03b8f8c
Compare
pkg/cmd/start/start.go
Outdated
| }, startStore) | ||
| if err != nil { | ||
| if !piped { | ||
| t.Vprintf("Error starting %s: %s\n", instanceName, err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this purposely doesn't return the error, just prints it?
pkg/cmd/start/start.go
Outdated
| WorkspaceClass string | ||
| Detached bool | ||
| InstanceType string | ||
| Piped bool // true when stdout is piped to another command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this field ever read?
| stdinPiped := IsStdinPiped() | ||
| if stdinPiped { | ||
| scanner := bufio.NewScanner(os.Stdin) | ||
| for scanner.Scan() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no scanner.err check?
- Return errors from runBatchStart instead of silently swallowing them - Remove unused Piped field from StartOptions - Add scanner.Err() check after stdin scan loop in piping.go
Summary
Add stdin piping and improved output for CLI composability, enabling Unix-style command chaining.
Changes
Stop/Start/Delete
--allflag to stop commandLs Improvements
--jsonflag for JSON outputbrev ls orgsExamples
Test plan
echo "instance" | brev stopworksbrev stop inst1 inst2works with multiple argsbrev ls --jsonoutputs valid JSONbrev ls | grepworks (plain table when piped)brev stop --allstops all running instancesbrev ls orgs --jsonoutputs valid JSON