feat(shopping-list): add --extra for items no recipe calls for - #457
Merged
Conversation
Adds a repeatable --extra flag to `cook shopping-list` for the paper
towels and bin bags that belong on the same shopping trip but that no
recipe asks for. Each value is a Cooklang ingredient written without the
leading @: a bare name for something with no amount, or the brace form
(eggs{12}, flour{200%g}) to give one.
Extra items are aggregated with the recipe ingredients rather than kept
apart, so one that shares a name with an ingredient a recipe already
needs merges into it, lands in its aisle category, and is subtracted
from by the pantry.
Closes cooklang#175
Member
|
Nice! Thank you |
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.
This adds a
--extraflag tocook shopping-listso you can drop items no recipe calls for onto the same list — the paper towels and bin bags from #175.Each
--extravalue is a Cooklang ingredient written without the leading@: a bare name like--extra "paper towels"for something with no amount, or the brace form (--extra "eggs{12}",--extra "flour{200%g}") when you want one. Repeat the flag per item. I leaned on cooklang's own ingredient parsing here rather than inventing a second little quantity syntax, so amounts and units behave exactly the way they do in a recipe, and a stray@typed out of habit is tolerated instead of doubled into the name.Extra items are aggregated with the recipe ingredients rather than kept in a section of their own, which felt like the least surprising behaviour: an extra that shares a name with something a recipe already needs merges into it, gets grouped into its aisle category, and is subtracted from by the pantry — the same path every ingredient already takes.
The field lives on
GenerateRequestin cookcli-core and defaults to empty, so existing callers are unaffected; the CLI just passes the flag through. Tests cover the bare, multi-word and quantified cases, merging with a matching recipe ingredient, aisle grouping, pantry subtraction, the tolerated@, and the error for an empty entry. Docs updated indocs/shopping-list.md.Closes #175