Skip to content

fix(shopping-list): error clearly on a directory without recipes - #732

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
drawmeanelephant:fix/723-menu-only-dir
Oct 17, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
drawmeanelephant:fix/723-menu-only-dir

Conversation

@drawmeanelephant

@drawmeanelephant drawmeanelephant commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #723

cook sl <dir> expands only *.cook, so a directory holding only .menu files fell back to the raw argument and died with Recipe not found: <dir>. (Expanding .menu files was considered, but menus usually reference sibling recipes, so expansion would count those recipes twice.) Now a directory that yields no .cook files errors with Directory '<dir>' contains no .cook files, naming how many .menu files it has and that they can be passed by name; a mixed directory warns rather than silently skipping.

Test plan

  • cook sl plans/ where plans/ holds only week.menu/weekend.menu → Error: Directory 'plans' contains no .cook files — it has 2 .menu file(s) that can be passed by name (previously Recipe not found)
  • New integration test test_shopping_list_menu_only_directory_errors_clearly
  • Existing .cook-only expansion and hidden-file tests unchanged

@LeMyst LeMyst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The clearer error for an empty directory is good, but expanding .menu files found in a directory counts recipes twice.

Menus usually reference recipes that sit in the same folder. In the shipped seed/, Weekly Plan.menu and 2 Day Plan.menu both reference @./lamb-chops{}, next to lamb-chops.cook. Before this PR, cook shopping-list seed/ listed the top-level recipes once. With it, lamb-chops and the other menu recipes are added again through each menu, plus the menus' loose ingredients (oats, milk…), so quantities are silently inflated.

Skipping .menu files doesn't look like a deliberate choice: the ext == "cook" filter dates from the new UI (e200582) and probably predates menus. But including them changes what a directory means. Since #723 allows either fix ("include menus OR error accurately"), I'd suggest keeping only the error part. A directory with no .cook files would fail with an accurate message, ideally saying it holds N .menu files that can be passed explicitly. Menus would not be expanded.

A small integration test for the empty-directory message would be nice.


🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.

@drawmeanelephant

Copy link
Copy Markdown
Contributor Author

Reworked per review: directories no longer expand .menu files — a directory with no .cook files now fails with an accurate message that names how many .menu files it holds and that they can be passed by name. Added an integration test for the message.

@drawmeanelephant drawmeanelephant changed the title fix(shopping-list): expand .menu files in directories, error clearly fix(shopping-list): error clearly on a directory without recipes Oct 14, 2026
@LeMyst

LeMyst commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the rework. I checked it against the cases from the first review. A directory of only menus now fails with Directory 'menus' contains no .cook files — it has 2 .menu file(s) that can be passed by name. A directory mixing .cook and .menu gives the same list as passing the recipes by name, and cook shopping-list seed matches main exactly. Nonexistent paths still say "Recipe not found". fmt, clippy and tests pass locally, and CI is green.

One optional tidy-up: the new test could use the shopping_list_in() helper further down the file, so it runs with an isolated config dir like CLAUDE.md asks. Otherwise this looks good to merge.


🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.

A directory holding only .menu files fell back to being treated as a
recipe path, surfacing a misleading "recipe not found". Report what the
directory actually contains, noting any .menu files that can be passed
by name. Menus are not expanded from a directory: they usually reference
sibling recipes, so expanding them would count those recipes twice.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@drawmeanelephant

Copy link
Copy Markdown
Contributor Author

Done on d12b1e4 — the test now goes through shopping_list_in(), so it runs under the isolated config dir (and --plain) like its neighbours.

@LeMyst
LeMyst merged commit 5e4e822 into cooklang:main Oct 17, 2026
5 checks passed
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.

shopping-list on a directory with only .menu files errors misleadingly

2 participants