feat(list): flatten custom fields in --json output #39

Merged
David merged 1 commit from feat/list-flatten-custom-fields into main 2026-05-15 13:09:58 +02:00
Owner

Summary

  • yt list --json previously serialized each issue with the raw customFields array, which renders in nu | from json as an unreadable list of {name, value} records (per attached screenshot).
  • This PR flattens that array: each custom field name is promoted to a top-level key alongside idReadable, summary, and sprints, with the value rendered via the same presentation logic the text table uses (State -> "In Review", Assignee -> "NiceGuyIT", etc.). The result is one nushell column per field.
  • New --custom-fields flag appends the original customFields array to each row in addition to the flattened keys (not as a replacement), for callers that need the raw structure (e.g. enum bundle ids, full assignee object).
  • Custom fields named idReadable / summary / sprints / customFields are skipped so they cannot shadow the built-in row keys.
  • Enabled serde_json's preserve_order feature so the JSON key order is stable (idReadable, summary, custom fields in server order, sprints, optional customFields) instead of the alphabetical order BTreeMap would otherwise produce.
  • Behavior of the non-JSON table output is unchanged.

Test plan

  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --all-targets (212 passed; three new tests cover flatten ordering, the --custom-fields flag, and shadow-key skipping)
  • Smoke test against a real YouTrack instance: yt list --query "#Unresolved for:me" --json | from json shows one column per custom field; rerun with --custom-fields to confirm the raw array is appended.
## Summary - `yt list --json` previously serialized each issue with the raw `customFields` array, which renders in `nu | from json` as an unreadable list of `{name, value}` records (per attached screenshot). - This PR flattens that array: each custom field name is promoted to a top-level key alongside `idReadable`, `summary`, and `sprints`, with the value rendered via the same presentation logic the text table uses (`State` -> "In Review", `Assignee` -> "NiceGuyIT", etc.). The result is one nushell column per field. - New `--custom-fields` flag appends the original `customFields` array to each row in addition to the flattened keys (not as a replacement), for callers that need the raw structure (e.g. enum bundle ids, full assignee object). - Custom fields named `idReadable` / `summary` / `sprints` / `customFields` are skipped so they cannot shadow the built-in row keys. - Enabled `serde_json`'s `preserve_order` feature so the JSON key order is stable (`idReadable`, `summary`, custom fields in server order, `sprints`, optional `customFields`) instead of the alphabetical order BTreeMap would otherwise produce. - Behavior of the non-JSON table output is unchanged. ## Test plan - [x] `cargo fmt --check` - [x] `cargo clippy --all-targets -- -D warnings` - [x] `cargo test --all-targets` (212 passed; three new tests cover flatten ordering, the `--custom-fields` flag, and shadow-key skipping) - [ ] Smoke test against a real YouTrack instance: `yt list --query "#Unresolved for:me" --json | from json` shows one column per custom field; rerun with `--custom-fields` to confirm the raw array is appended.
feat(list): flatten custom fields in --json output
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 18s
Create release / Create release from merged PR (pull_request) Has been skipped
39ff3d14fe
Each issue in `yt list --json` now serializes as a flat object: `idReadable`, `summary`, every custom field promoted to a top-level key (presentation string), then `sprints`. This lets `from json` in nushell render one column per field instead of a nested `customFields` list of records that was unreadable in the table view.

The raw `customFields` array is no longer in the default output. Add `--custom-fields` to append it (in addition to, not in place of, the flattened keys) for callers that need the full structure.

Enable serde_json's `preserve_order` feature so the JSON key order matches the insertion order above instead of being sorted alphabetically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
David merged commit 706769ae3e into main 2026-05-15 13:09:58 +02:00
David deleted branch feat/list-flatten-custom-fields 2026-05-15 13:09:58 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/youtrack-cli!39
No description provided.