Skip to content

feat: add products & components command groups (CU-868k0t6gb) - #1

Merged
obitum merged 6 commits into
mainfrom
feat/products-components
Jun 20, 2026
Merged

feat: add products & components command groups (CU-868k0t6gb)#1
obitum merged 6 commits into
mainfrom
feat/products-components

Conversation

@obitum

@obitum obitum commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds read-only products and components command groups to the CLI — the CLI side of API Story A3 (Products/Components read). Both resources share the same API shape (Project records distinguished by output_type), so they share a single core (commands/projects.go); the two registration files are thin.

  • craftybase products list / craftybase products show <id>
  • craftybase components list / craftybase components show <id>

list columns: ID · NAME · SKU · CATEGORY · VARIANTS · ON HAND · AVAILABLE · UNIT PRICE. show adds STATE and a VARIATIONS (n) sub-table (ID · SKU · ATTRIBUTES · ON HAND · AVAILABLE · UNIT PRICE · DEFAULT), with a No active variations. empty state. --json / --ndjson carry the full nested variations; unit_price is financial-gated (renders in tables, omitted in JSON for view-only keys). Filters mirror materials: --sku, --name, --categorycategory_name, --state, plus --page/--per-page/--all/--ndjson.

PRD & plan live in the vault: CU-868k0t6gb/prd-products-components.md, plan-products-components.md.

Commits

  • b33b5cd fix: align table columns under color — drops text/tabwriter, which counted ANSI escape bytes as visible width and misaligned colored headers. Separable bugfix bundled here (the products/components tables render through FormatTable); happy to split into its own PR if preferred.
  • f531790 fix: read current_page from the list meta envelope (was reading the non-existent page key)
  • bc2cd2e feat: project/variation models + table/show renderers (pure, unit-tested)
  • b34fb36 feat: products list/show command group
  • 99a194f feat: components list/show command group

Testing

  • go test ./... -race green, go vet ./... clean, gofmt/goimports clean on all changed files.
  • New tests: pure render-helper unit tests; a color-alignment regression test (color-on, ANSI-stripped == color-off, byte for byte); products/components fixture contract checks (money string pair, flat category, variations array, current_page, no projects leak); the root-help command-coverage invariant; branded-help golden regenerated (+products, +components lines).

Follow-ups (not blocking — tracked for a separate ticket)

  • Fold materials onto the shared core before A4/Recipes lands to avoid a third clone of the list/show flow; consider renaming the core to a resource-neutral symbol.
  • Reconcile PRD FR-7/AC-5 prose: the resource-labelled 404 ("Product not found.") is supplied by the API and surfaced by the CLI, not constructed CLI-side.
  • --json --all currently falls through to the table render (latent in materials too) — decide between erroring or emitting a JSON array.

Ticket: CU-868k0t6gb (Story A7 of the Public API epic).

🤖 Generated with Claude Code

obitum and others added 6 commits June 19, 2026 21:48
…t6gb)

Replace hardcoded "Craftybase"/"craftybase"/docs URL in the root help
screen with brand.ProductName, brand.BinaryName, and a new brand.DocsURL
so the planned Stocksmith rebrand stays a contained change. Output is
byte-identical (golden + suite unchanged). The ASCII wordmark is noted as
the one inherent rebrand touch-point that cannot be centralized.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implement products command group with HTTP list/show runners, matching
materials architecture. Adds projectResource factory pattern, projectListFlags
for list filtering (sku, name, category, state, page, per-page, all), and
runProjectList/runProjectShow handlers with JSON/NDJSON/table branching.

Include contract tests locking API envelope shape, money format, and param
mapping (--category → category_name). Update root help coverage invariant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@obitum
obitum merged commit c993c02 into main Jun 20, 2026
1 of 2 checks passed
@obitum
obitum deleted the feat/products-components branch June 20, 2026 04:07
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