feat(field): read and write custom fields with per-type value coercion - #44
Conversation
Implements the GetCustomFields and SetCustomFieldValue methods that internal/interfaces/api.go has declared since the interface was written, and adds the `cu field` command over them: list, get, set, clear. Values are coerced to the shape each type expects rather than passed through as strings — epoch milliseconds for dates, resolved option ids for dropdowns and labels — so `cu field set <task> Machine "Chilastra,Sunrunner"` works with names. Unknown option names are rejected with the valid set; unsupported types (formula, rollup, progress) refuse rather than guess, since a silently wrong write is worse than a clear error. Fields are resolved from the task's own list, so space- and folder-level fields resolve without the caller knowing where they were defined. An ambiguous field name is an error rather than a first match. Addresses PROJECT_SPEC §13 open question 1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aqbmccWm1tqttmBUCR5rv ClickUp: 86dxbeqyt
Review — no blockersGood shape overall. Non-blocking
|
Summary
Implements custom field read/write and adds a
cu fieldcommand over it.GetCustomFieldsandSetCustomFieldValuehave been declared ininternal/interfaces/api.gosince the interface was written, with no implementation behind them. This adds those (plusRemoveCustomFieldValue) onapi.Clientand exposes:Values are coerced per type rather than passed through as strings, which is the substance of the change — ClickUp expects epoch milliseconds for dates, option UUIDs for dropdowns, and an array of option UUIDs for labels. So names work on the command line:
Dates accept
today,now,2006-01-02, RFC3339, or epoch milliseconds.Design choices worth reviewing:
formula,rollup,manual_progressand friends returnsetting fields of type "manual_progress" is not supported— a silently wrong write is worse than a clear error.Addresses PROJECT_SPEC §13 open question 1 ("Support ClickUp Custom Fields in JSON output?") — all four output formats share one row shape, so
-o jsongives{name, type, id, value}.Tests
TestFindCustomField,TestCoerceCustomFieldValue,TestFormatCustomFieldValuecover every supported type, both resolution directions (name→id on write, id→name on read), and each rejection path. Set/get/clear round-trips were also exercised live against a real workspace.Checklist
./scripts/ci.shpasses locally — excepterrcheck, which reports the same 27 pre-existing findings onmain, none in files this PR touchescu docs markdown --dir docs/site/commands) and added to the mkdocs nav