Skip to content

Add filter groups with a lone - and +, and treat a lone - as a word - #375

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

CLHatch merged 1 commit into
mainfrom
compose-filter-sets

Conversation

@CLHatch

@CLHatch CLHatch commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Adds a simpler way to write compose filters: a lone - or + between groups of names. It's also the form that avoids an easy mistake: -c update -sonarr is read as the flags -s -o -n -a -r -r, while -c update - sonarr is a filter.

ds2 -c update - sonarr            every service but sonarr
ds2 -c update - sonarr radarr     every service but those two
ds2 -c update radarr + sonarr     just those two

Groups

  • A lone - or + takes the words after it, up to the next one, as a group. The groups apply left to right, starting from every service: - removes the group's services, + adds them. With no operator in front, the first group narrows to its matches.
  • Within a group, words with the same key are one list ("or") and different keys narrow ("and"). Plain names alongside filter words therefore keep meaning "these apps", as they do without filters. service:sonarr service:radarr now means both; before, it was an empty-result error.
  • The per-word forms (service:-sonarr, service:+sonarr) still work, within a group.
  • A - group protects what it names from being brought back as a dependency, like a - word, even if an earlier group already left it out. The refusal names the group: "- sonarr excludes sonarr, but seerr depends on it…".

New refusals

  • A + that would add to every service changes nothing, so it's refused with the fix: "+ sonarr adds to every service, so it changes nothing; to act on sonarr only, write sonarr". This covers the + group and the existing service:+x word, which as a first word used to silently mean "everything".
  • An operator with nothing after it: "- needs a filter after it".

Parser

  • A lone - is now an ordinary word, never an option. Everything else starting with - is parsed as before.
  • Commands that take app or container names but no filters yet (-a, -r, -s, --status-enable/--status-disable, --env-appvars/--env-appvars-lines, --start, --stop, --restart, --logs) refuse filter syntax, a lone -/+ or a service: word, with the usual caret error: '-r' doesn't support filters.
  • Other commands get a lone - as an ordinary value and apply their own checks ('-' is an invalid variable name.), or the caret's "invalid option" where they take no arguments.
  • -c without a compose command (-c - swag) stays an error on purpose.

The -c usage text leads with these forms, as a short list of examples.

Testing

Unit tests cover the parser (a lone - passed as a word with flags around it, the refusals and their caret positions, colons left to commands that take them), groups (left to right, lists, narrowing, protection, re-adding), every new error, and the dependency refusal through a - group.

Tested on a Linux test host: - x, - x y, x + y, plain names, the + and dangling-operator refusals, a refused update - <dependency>, the parser refusals with their carets, and -c status -swag still failing safely as flags.

A lone "-" or "+" in a compose filter takes the words after it, up to
the next one, as a group; the groups apply left to right, starting from
every service, "-" removing and "+" adding:

  ds2 -c update - sonarr            every service but sonarr
  ds2 -c update - sonarr radarr     every service but those two
  ds2 -c update radarr + sonarr     just those two

Within a group, words with the same key are one list and different keys
narrow, so plain names keep meaning "these apps" alongside filter words.
service:sonarr service:radarr now means both, where it was an empty
result. A "-" group protects what it names from being brought back as a
dependency, like a "-" word, even if an earlier group left it out.

A "+" that would add to every service changes nothing and is refused,
for the "+" group and the existing service:+x word alike, as is an
operator with nothing after it.

The parser treats a lone "-" as an ordinary word, never an option.
Commands that take app or container names but no filters yet (-a, -r,
-s, --status-enable/-disable, --env-appvars(-lines), --start, --stop,
--restart, --logs) refuse filter syntax with the usual caret error:
"'-r' doesn't support filters."
@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 20 hours and 4 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@CLHatch
CLHatch merged commit 9bd8b21 into main Nov 29, 2026
6 checks passed
@CLHatch
CLHatch deleted the compose-filter-sets branch November 29, 2026 09:15
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