feat(run): add --except to run every service but the named ones - #513
feat(run): add --except to run every service but the named ones#513jongio wants to merge 1 commit into
Conversation
Add a `--except` flag to `azd app run` as the complement of `--service`. It starts every service except the comma-separated names given. The two flags are mutually exclusive, and an unknown excluded name fails with the list of available services so a typo does not silently run more than intended. Closes #508 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Website Preview Your PR preview is ready! 📎 Preview URL: https://jongio.github.io/azd-app/pr/513/ This preview will be automatically cleaned up when the PR is closed. |
🚀 Test This PRA preview build ( 🌐 Website PreviewLive Preview: https://jongio.github.io/azd-app/pr/513/ One-Line Install (Recommended)PowerShell (Windows): iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/install-pr.ps1) } -PrNumber 513 -Version 0.19.5-pr513"Bash (macOS/Linux): curl -fsSL https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/install-pr.sh | bash -s 513 0.19.5-pr513UninstallWhen you're done testing: PowerShell (Windows): iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/uninstall-pr.ps1) } -PrNumber 513"Bash (macOS/Linux): curl -fsSL https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/uninstall-pr.sh | bash -s 513Build Info:
What to Test: |
wbreza
left a comment
There was a problem hiding this comment.
Clean, well-scoped addition of --except with fail-fast mutual exclusion, safe unknown-name handling, and thorough unit tests. Approving.
What stood out
- Fail-fast validation —
--service/--exceptmutual exclusion is checked early inrunWithServices, before any trust or dependency work, so invalid combinations fail immediately. - Safe exclusion semantics —
excludeServicestrims whitespace and errors on unknown names with the available-service list, so a typo cannot silently widen the run set. - Thorough tests —
run_except_test.gocovers removal, multi-exclude, whitespace trimming, unknown names, exclude-all, flag routing, and mutual exclusion. - Docs parity — Both
cli-reference.mdandcommands/run.mddocument the flag, its examples, and the mutual-exclusion constraint.
Improvement opportunities
- [O-001] Align
--serviceparsing with--except(trim + unknown-name error) (Optional) —cli/src/cmd/app/commands/run.go:393
| excludeSet := make(map[string]bool, len(exclude)) | ||
| var unknown []string | ||
| for _, name := range exclude { | ||
| name = strings.TrimSpace(name) |
There was a problem hiding this comment.
💡 Improvement Opportunity (optional — not required to merge)
Benefit: --except trims whitespace and rejects unknown names, but --service (via filterServices / service.FilterServices) does neither — --service web, api silently drops api, and an unknown --service name is silently ignored. Aligning the two removes a surprising asymmetry between the complementary flags.
Effort: Small — reuse the trim + membership-check pattern already in excludeServices for the --service path.
Optionality: Optional — pre-existing behavior, outside this PR''s stated scope.
Sketch: In filterServices, strings.TrimSpace each name and collect unknowns into the same "unknown service(s)" error style used by excludeServices.
Summary
Adds
--excepttoazd app runso you can start every service and skip only the one(s) you name. It is the complement to--service: one names what runs, the other names what to leave out.This is handy when a project has one heavy or noisy service you do not want locally (a background worker, a scheduled job) but you still want everything else, without having to spell out the full list in
--service.Behavior
--serviceand--exceptare mutually exclusive. Passing both returns a clear error instead of guessing.--exceptfails with the list of available services, so a typo does not silently start more than you intended.--servicebehavior is unchanged.Details
selectRunServices/excludeServices, kept separate from the run flow so it is unit tested without spinning anything up.runWithServices, before any dependency or trust work, so it fails fast.--exceptgets service-name shell completion, same as--service.Testing
go build ./...go vet ./src/cmd/app/commands/...go test ./src/cmd/app/commands/ -count=1 -shortgolangci-lint run ./src/cmd/app/commands/...Closes #508