Skip to content

feat(shopping-list): add --pantry and --ignore-pantry flags#340

Merged
dubadub merged 5 commits into
mainfrom
feat/shopping-list-pantry-flags
May 15, 2026
Merged

feat(shopping-list): add --pantry and --ignore-pantry flags#340
dubadub merged 5 commits into
mainfrom
feat/shopping-list-pantry-flags

Conversation

@dubadub
Copy link
Copy Markdown
Member

@dubadub dubadub commented May 15, 2026

Summary

  • Add --pantry <path> to cook shopping-list, mirroring the existing --aisle <path>. Overrides the auto-discovered pantry file.
  • Add --ignore-pantry boolean flag that skips pantry loading and subtraction entirely.
  • When both are passed, --ignore-pantry wins (no file I/O on the explicit path).

Test plan

  • cargo fmt, cargo clippy --all-targets -- -D warnings, cargo build all clean
  • Default behavior: cook shopping-list --base-path ./seed "Salads/Caprese.cook" subtracts pantry items (fresh basil, olive oil) as before
  • --ignore-pantry: pantry-only ingredients reappear at full recipe quantities
  • --pantry /tmp/test-pantry.conf: custom file overrides auto-discovery (only items in the custom file are subtracted)
  • --ignore-pantry --pantry /does/not/exist.conf: succeeds, no read attempt, same output as --ignore-pantry alone
  • cook shopping-list --help shows both new flags

When --pantry is passed explicitly, surface read failures as errors
instead of silently warning and producing an unfiltered list. Auto-
discovered pantry paths still fall through silently, since absence is
expected.

Also remove the docs/superpowers/ planning artifacts that were
inadvertently committed with the feature.

Co-authored-by: Claude <noreply@anthropic.com>
@cooklang cooklang deleted a comment from claude Bot May 15, 2026
@claude
Copy link
Copy Markdown

claude Bot commented May 15, 2026

Code Review — feat(shopping-list): add --pantry and --ignore-pantry flags

Overview

This PR adds two new flags to cook shopping-list that fill a genuine ergonomic gap: the ability to specify a custom pantry file (mirroring the existing --aisle flag) and the ability to skip pantry subtraction entirely. The implementation is small (26 lines added) and well-scoped.


What works well

  • Minimal footprint. The change touches exactly one Rust file and follows the existing --aisle pattern closely, making it easy to review and reason about.
  • Correct precedence. --ignore-pantry short-circuits before any file I/O, so --ignore-pantry --pantry /bad/path succeeds silently as documented — sensible UX.
  • Appropriate error differentiation. Explicit --pantry paths that fail to load return a hard error; auto-discovered paths emit a warning (backward-compatible). This is the right distinction.
  • Flag naming. --ignore-pantry mirrors the existing --ignore-references, which is consistent.

Issues and suggestions

Minor: explicit_pantry is computed before ignore_pantry is checked

let explicit_pantry = args.pantry.is_some();   // always evaluated
let pantry_path = if args.ignore_pantry {
    None                                        // explicit_pantry never read here
} else {
    args.pantry.or_else(|| ctx.pantry())
};

When --ignore-pantry is set, explicit_pantry is true but is never accessed (the if let Some(path) block is skipped). It's harmless today but could confuse a future reader who sees the variable and wonders why it's set to true even though the pantry is being ignored.

Suggestion: Move the variable inside the else branch, or use a comment to make the invariant explicit:

// explicit_pantry is only meaningful when pantry_path is Some(_)
let explicit_pantry = args.pantry.is_some();

Minor: Existing warning doesn't include the auto-discovered path

The pre-existing warn! still reads:

warn!("Failed to read pantry file: {}", e);

The new hard-error arm correctly includes the path ("Failed to read pantry file '{}': {}", path, e). The warning could be updated to match for consistency and debuggability — it's easy to not know which path was tried. Not a blocker, but while the area is open this is a good time to fix it.

docs/superpowers/ artifacts should not be committed

The PR includes two Markdown files in docs/superpowers/specs/ and docs/superpowers/plans/ that appear to be internal agentic scaffolding artifacts (they contain lines like REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development). These are process/tooling artifacts and likely do not belong in the shipped repository. I'd recommend removing both before merge.

Missing user-facing documentation

The spec itself calls this out as future work, but it's worth flagging: docs/shopping-list.md (if it exists) should mention the two new flags. If there's a man-page or CLI reference, that too. Not a blocker, but ideally this lands in the same PR or a fast-follow.

No --ignore-aisle counterpart

--aisle now has a --pantry peer but no --ignore-aisle. This asymmetry is fine for now, but it's worth opening a follow-up issue so the two options stay in sync over time.


Summary

The Rust change itself is correct and clean. Two action items before merge:

  1. Remove docs/superpowers/specs/2026-05-15-shopping-list-pantry-flags-design.md and docs/superpowers/plans/2026-05-15-shopping-list-pantry-flags.md — these are internal scaffolding artifacts, not repo documentation.
  2. Consider updating the existing warn! to include the path for consistency with the new error message.

Everything else looks good to go.

@cooklang cooklang deleted a comment from claude Bot May 15, 2026
@cooklang cooklang deleted a comment from claude Bot May 15, 2026
@cooklang cooklang deleted a comment from claude Bot May 15, 2026
@dubadub dubadub merged commit dd5264b into main May 15, 2026
2 checks passed
@dubadub dubadub deleted the feat/shopping-list-pantry-flags branch May 15, 2026 18:38
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