Repository navigation
Add filter groups with a lone - and +, and treat a lone - as a word - #375
Merged
Merged
Conversation
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."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -sonarris read as the flags-s -o -n -a -r -r, while-c update - sonarris a filter.Groups
-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.service:sonarr service:radarrnow means both; before, it was an empty-result error.service:-sonarr,service:+sonarr) still work, within a group.-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
+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 existingservice:+xword, which as a first word used to silently mean "everything".Parser
-is now an ordinary word, never an option. Everything else starting with-is parsed as before.-a,-r,-s,--status-enable/--status-disable,--env-appvars/--env-appvars-lines,--start,--stop,--restart,--logs) refuse filter syntax, a lone-/+or aservice:word, with the usual caret error:'-r' doesn't support filters.-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.-cwithout a compose command (-c - swag) stays an error on purpose.The
-cusage 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 refusedupdate - <dependency>, the parser refusals with their carets, and-c status -swagstill failing safely as flags.