Skip to content

shopping-list: -f yaml ignores --plain #419

Description

@dubadub

--plain is documented as "Display ingredients without aisle categories", and the human, JSON and Markdown writers all honour it. The YAML writer does not — it always categorises.

Reproduction

mkdir -p config
printf 'Mix @flour{1%%c} and more @flour{200%%g}.\n' > bake.cook
printf '[baking]\nflour\n' > config/aisle.conf

cook shopping-list --plain -f json bake.cook
cook shopping-list --plain -f yaml bake.cook

JSON correctly drops the categories:

[{"name":"flour","quantity":[...]}]

YAML keeps them:

- category: baking
  items:
  - name: flour
    quantity:
    - ...

Cause

In src/shopping_list.rs, the other three writers take the flag:

build_human_table(list, &aisle, args.plain)
build_json_value(list, &aisle, args.plain)
build_md_value(list, &aisle, args.plain, args.ingredients_only)

build_yaml_value(list, &aisle) has no plain parameter, so the flag cannot reach it.

Impact

Anyone scripting against -f yaml --plain gets a different document shape from -f json --plain, silently. No error, no warning.

Noticed while adding characterization tests for cook shopping-list ahead of extracting it into a library crate (see #415 for why that command had no coverage).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions