Skip to content

feat(shopping-list): leave optional ingredients out unless --include-optional - #592

Merged
dubadub merged 1 commit into
mainfrom
feat/optional-shopping-list
Oct 3, 2026
Merged

dubadub merged 1 commit into
mainfrom
feat/optional-shopping-list

Conversation

@dubadub

@dubadub dubadub commented Sep 30, 2026

Copy link
Copy Markdown
Member

Part 1 of the CookCLI side of spec proposal 0018.

A recipe now contributes only its required ingredients to cook shopping-list. --include-optional adds the optional ones — and everything an optional recipe reference @?./sauce{} adds — marked as optional and kept apart from required amounts of the same ingredient:

$ cook shopping-list Eggs.cook --plain --include-optional
eggs              2
butter            10 g
toast             2 slices
chives (optional)

JSON/YAML items get "optional": true (omitted when false, so existing output is unchanged).

Core (cookcli-core)

  • extract_ingredients accumulates into ShoppingIngredients { required, optional } instead of one IngredientList (breaking for core consumers).
  • ExtractOptions::include_optional, GenerateRequest::include_optional, ListItem::optional.
  • Optional items follow required ones in the plain view and within each aisle category; categories keep aisle order.
  • Pantry stock counts against the required amount first; an ingredient needed both ways keeps its whole optional amount rather than having the same stock subtracted twice.

Not yet

  • The web server still includes optional ingredients merged as before (include_optional: true + merge), so the web list does not regress. Part 2: ? name{qty} selection lines in .shopping-list and choosing optional ingredients when adding a recipe in the web UI.
  • Part 3: pantry-based recipe matching ignoring missing optional ingredients.

Tests: new core tests for default exclusion, marking, separate aggregation (within and across recipes), optional references, categorisation, pantry; a formatter test for human/markdown/JSON. cargo test --all-features --workspace passes.

(Replaces #591, which GitHub closed when its stacked base branch was deleted.)

…optional

Following spec proposal 0018, a recipe contributes only its required
ingredients to a shopping list. --include-optional adds the optional
ones (and everything an optional recipe reference adds), marked
"(optional)" in human and markdown output and "optional": true in
JSON/YAML, and kept apart from required amounts of the same ingredient.

Core: extract_ingredients now accumulates into ShoppingIngredients
{ required, optional }; ExtractOptions and GenerateRequest gain
include_optional; ListItem gains optional. Pantry stock counts against
the required amount first.

The web server keeps including optional ingredients, merged as before,
until the web UI can choose them.
@dubadub
dubadub merged commit e389b43 into main Oct 3, 2026
4 of 5 checks passed
@dubadub
dubadub deleted the feat/optional-shopping-list branch October 3, 2026 14:37
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