Skip to content

feat: support custom properties on beans (Refs: beans-digu)#107

Open
hmans wants to merge 1 commit intomainfrom
feat/custom-properties
Open

feat: support custom properties on beans (Refs: beans-digu)#107
hmans wants to merge 1 commit intomainfrom
feat/custom-properties

Conversation

@hmans
Copy link
Copy Markdown
Owner

@hmans hmans commented Mar 7, 2026

Summary

Adds support for attaching arbitrary key-value metadata to beans via a properties field in YAML frontmatter.

Bean: beans-digu — "Support custom properties on beans"

Changes

Data Model (internal/bean/bean.go)

  • Added Properties map[string]any field to Bean, frontMatter, and renderFrontMatter structs
  • Added helper methods: SetProperty(key, value), UnsetProperty(key), GetProperty(key)
  • UnsetProperty normalizes empty maps to nil (so omitempty works correctly)
  • ETag and MarshalJSON work automatically — no changes needed

GraphQL Schema

  • Added scalar JSON mapped to gqlgen built-in graphql.Map
  • Added properties: JSON to Bean type and CreateBeanInput
  • Added to UpdateBeanInput:
    • properties: JSON — replace all (mutually exclusive with set/unset)
    • setProperties: JSON — merge/upsert specific keys
    • unsetProperties: [String!] — remove specific keys

CLI

  • beans create --set key=value (repeatable) — set properties at creation time
  • beans update --set key=value --unset key (repeatable) — granular property updates
  • beans show — displays properties section between relationships and body
  • YAML-based auto type detection: 3→int, true→bool, 4.5→float, text→string

Tests

  • Bean model: parse, render, roundtrip (type preservation), helpers, ETag, JSON serialization
  • GraphQL resolvers: create with properties, replace-all, set/unset, mutual exclusivity, normalize to nil
  • CLI: parsePropertyFlags table-driven tests (string, int, bool, float, empty, errors)

Example Usage

# Create with properties
beans create "Fix auth" -t bug --set estimate=3 --set author=alice --set reviewed=true

# Update properties
beans update <id> --set estimate=5 --unset reviewed

# View properties
beans show <id>        # styled output with properties section
beans show <id> --json # JSON with properties object
beans show <id> --raw  # YAML frontmatter with properties block

YAML Frontmatter

---
title: Fix authentication bug
status: in-progress
type: bug
properties:
    author: alice
    estimate: 3
    reviewed: true
---

Not in scope

  • Filtering/searching by property values (future work)
  • Property key name validation
  • TUI property editing

- Add Properties map[string]any field to Bean with SetProperty/UnsetProperty/GetProperty helpers
- Add scalar JSON to GraphQL schema with properties on Bean, CreateBeanInput, UpdateBeanInput
- Support replace-all (properties) and granular (setProperties/unsetProperties) update semantics
- Add --set key=value flag to create and update commands, --unset flag to update
- Display properties in beans show output (styled, raw, JSON)
- YAML-based auto type detection for CLI values (int, float, bool, string)
- Full test coverage across bean model, GraphQL resolvers, and CLI flag parser

Refs: beans-digu
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