Skip to content

Add service filters to -c compose commands - #373

Merged
CLHatch merged 1 commit into
mainfrom
compose-filters
Nov 29, 2026
Merged

CLHatch merged 1 commit into
mainfrom
compose-filters

Conversation

@CLHatch

@CLHatch CLHatch commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Adds filters to -c compose commands, so a command can act on "everything but" a service without listing every other one by hand. The motivating case: updating every app while one instance is busy with a long job that a recreate would kill.

ds2 --no-deps -c update service:-sonarr

For now filters are -c only, and service: is the only key.

Filters

A word with a key after the compose command is a filter. Words apply left to right, starting from every service in the project:

Word Effect
service:radarr,sonarr keep only these (bare narrows)
service:+sonarr add these back
service:-sonarr remove these
  • A comma means "or" within a word; a new word is the next step. = works like :, and names are matched without regard to case.
  • A plain app name next to filter words is a bare service: word. Without filter words, plain names behave exactly as before.

Safety

  • A filter that leaves no services is an error, never "every service". So is an unknown service name, mixing + and - in one word, or a list item that looks like another filter.
  • If the command would bring back a service a - word removed, through a dependency (or a dependent with -D, or a restart: true dependent for restart), it stops before asking. The message names every service that brings it back: "service:-sonarr excludes sonarr, but seerr depends on it: add --no-deps, or exclude seerr too". --no-deps acts on the filtered services only.
  • Services with a Compose profile are left out of the starting set, matching the rest of DS2, which never runs them. Naming one is a clear error rather than compose's "no such service: disabled".
  • A Filter … → N services line shows what the words resolved to. The question and the Running line list the resolved services, so the shown command is what runs.
  • -c run takes a job name and refuses a filter.

Related display fixes

  • With --no-deps, the question names what it leaves out ("…, without their dependencies: …", or "without the apps that restart with them" for restart), and the Running line shows --no-deps for up and restart.
  • pull showed --include-deps even with --no-deps; it now shows it only when dependencies are included.
  • A multi-service app's other services keep their service part in names: PaperlessNGX-redis instead of a second PaperlessNGX.
  • The -c usage text describes filters.

Testing

Unit tests cover the resolver (each operator, order, empty results, every error), the refusal for dependencies, dependents and restart dependents (several dependents, chains, merged sentences), profiled services, the preview reading profiles, and the --no-deps question wording.

Tested on a Linux test host: every error and word form, the refusal in both directions, filtered pull, restart and update, from the command line and the TUI console panel. Confirmed live on a production host: --no-deps -c update service:-sonarr updated 28 apps and left Sonarr's container untouched while its long-running job continued; the other Sonarr instances were recreated as intended.

Words with a key after a compose command pick the services it acts on:
service:-sonarr is every service but sonarr, service:radarr,sonarr only
those two, service:+sonarr adds sonarr. Words apply left to right,
starting from every service; a plain app name keeps only that app.
Plain names without filter words behave as before.

- A filter that leaves no services, names an unknown service, or mixes
  "+" and "-" in one word is an error and nothing runs.
- If the command would bring back a service a "-" word removed, as a
  dependency (or a dependent with -D or restart), it stops before asking
  and names every service that brings it back; --no-deps acts on the
  filtered services only.
- Services with a Compose profile, which DS2 never runs, are left out of
  the starting set, and naming one is an error.
- A "Filter ... -> N services" line shows what the words resolved to,
  and the question and Running line list the resolved services.

Related display fixes: with --no-deps the question names the
dependencies it leaves out and the Running line shows --no-deps (pull no
longer claims --include-deps), and a multi-service app's other services
keep their service part in names (PaperlessNGX-redis).
@sourcery-ai

sourcery-ai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Sorry @CLHatch, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 22 hours and 39 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@CLHatch
CLHatch merged commit 8a1bfe4 into main Nov 29, 2026
6 checks passed
@CLHatch
CLHatch deleted the compose-filters branch November 29, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant