Skip to content

feat(run): add --except to run every service but the named ones - #513

Open
jongio wants to merge 1 commit into
mainfrom
idea/run-except
Open

feat(run): add --except to run every service but the named ones#513
jongio wants to merge 1 commit into
mainfrom
idea/run-except

Conversation

@jongio

@jongio jongio commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Adds --except to azd app run so 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.

# Start everything except the worker
azd app run --except worker

# Skip several services
azd app run --except worker,cache

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

  • --service and --except are mutually exclusive. Passing both returns a clear error instead of guessing.
  • An unknown name passed to --except fails with the list of available services, so a typo does not silently start more than you intended.
  • Excluding every service reports that nothing remains to run.
  • The existing --service behavior is unchanged.

Details

  • The selection logic lives in selectRunServices / excludeServices, kept separate from the run flow so it is unit tested without spinning anything up.
  • The mutual-exclusion check runs early in runWithServices, before any dependency or trust work, so it fails fast.
  • --except gets service-name shell completion, same as --service.

Testing

  • go build ./...
  • go vet ./src/cmd/app/commands/...
  • go test ./src/cmd/app/commands/ -count=1 -short
  • golangci-lint run ./src/cmd/app/commands/...

Closes #508

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>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 13, 2026
@jongio jongio self-assigned this Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 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.

github-actions Bot added a commit that referenced this pull request Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Test This PR

A preview build (0.19.5-pr513) is ready for testing!

🌐 Website Preview

Live 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-pr513

Uninstall

When 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 513

Build Info:

What to Test:
Please review the PR description and test the changes described there.

@wbreza wbreza left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/--except mutual exclusion is checked early in runWithServices, before any trust or dependency work, so invalid combinations fail immediately.
  • Safe exclusion semanticsexcludeServices trims whitespace and errors on unknown names with the available-service list, so a typo cannot silently widen the run set.
  • Thorough testsrun_except_test.go covers removal, multi-exclude, whitespace trimming, unknown names, exclude-all, flag routing, and mutual exclusion.
  • Docs parity — Both cli-reference.md and commands/run.md document the flag, its examples, and the mutual-exclusion constraint.

Improvement opportunities

  • [O-001] Align --service parsing 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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add run --except flag to run all services except named ones

2 participants