Skip to content

feat(cli): localize event timestamps and make --show/--exclude/--show-only global (FT-1979)#46

Merged
joalves merged 2 commits into
mainfrom
feat/global-field-projection
Jun 1, 2026
Merged

feat(cli): localize event timestamps and make --show/--exclude/--show-only global (FT-1979)#46
joalves merged 2 commits into
mainfrom
feat/global-field-projection

Conversation

@joalves
Copy link
Copy Markdown
Collaborator

@joalves joalves commented Jun 1, 2026

Summary

Jira: FT-1979

Two related output-layer improvements, plus a release bump to 1.11.0.

1. Localized event timestamps

events json-layouts / json-values now render the last_event_at column as a locale- and timezone-localized date/time (via the existing formatDateTime helper), matching how created_at/updated_at are shown elsewhere. --raw keeps the original epoch-ms value.

2. Global --show / --exclude / --show-only

Previously these column-projection flags were declared per-command in 11 places and only worked on the ~10 commands with a summarized view. They're now global options on the root program (inherited like --raw/--output).

  • GlobalOptions + getGlobalOptions gain show/exclude/showOnly, and the --show-only is mutually exclusive… check is centralized there (was copy-pasted 11×).
  • Summarized commands keep their raw-backed applyShowExclude behavior (so --show can still add fields from the raw response) but source the field lists from globalOptions.
  • A new generic projectFields() runs in printFormatted and applies --exclude/--show-only to any printed data — arrays of objects, single objects, and the columnar {columnNames, rows} shape — so every command (events included) honors them, including under --raw. It's idempotent for commands that already projected at the summary layer.
  • A one-line note on each read command's --help surfaces the now-global flags.

--show is a no-op on commands without a summarized view (nothing extra to add); mutation commands (create/update/delete) print via printResult, not printFormatted, so they're intentionally not annotated.

Behavior notes

  • abs events json-layouts --exclude value_type → drops the column (verified end-to-end).
  • abs metrics get 42 --show-only id name → only those fields.
  • --show-only combined with --show/--exclude → clear error.
  • Help discoverability matches --raw/--output: flags appear under abs --help plus the per-command note.

Testing

  • tsc --noEmit, eslint, prettier --check: clean
  • Full suite: 2549 passed / 4 skipped
  • New unit tests: projectFields (object/array/columnar/idempotency), centralized mutex in getGlobalOptions, and printFormatted projection wiring
  • Migrated experiments/get.test.ts to drive the flags through getGlobalOptions

Notes

  • No JIRA ID was associated with this work — happy to add one to the title/branch if you'd like.
  • Carries the 1.10.0 → 1.11.0 minor bump per the release convention (1.10.0 is already published), so merging this publishes both features.

Summary by CodeRabbit

Release 1.11.0

  • New Features
    • Added global output-filtering options: --show, --exclude, and --show-only to control which fields appear in command results across the CLI.
    • Event timestamps now display as formatted dates instead of raw epoch values for improved readability.

joalves added 2 commits June 1, 2026 15:10
…-only global

Render the last_event_at column of `events json-layouts`/`json-values` as a
locale- and timezone-localized date/time (via the existing formatDateTime
helper), matching how created_at/updated_at are shown elsewhere. --raw keeps
the original epoch-ms value.

Promote --show, --exclude and --show-only to global options on the root
program (inherited like --raw/--output), instead of being declared per-command
in 11 places. The mutual-exclusivity check is centralized in getGlobalOptions.

Summarized commands keep their raw-backed applyShowExclude behavior (so --show
can still add fields from the raw response) but now source the field lists from
globalOptions. A new generic projectFields() runs in printFormatted and applies
--exclude/--show-only to any printed data — arrays of objects, single objects,
and the columnar {columnNames, rows} shape — so every command (events included)
honors them, including under --raw. The projection is idempotent for commands
that already projected at the summary layer.

A one-line note on each read command's --help surfaces the now-global flags.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Walkthrough

This PR introduces a global field-projection system for the CLI, moving output-filtering options (--show, --exclude, --show-only) from individual commands to the root program level. It adds a new projectFields utility to filter structured output, refactors all resource commands (experiments, customfields, goals, metrics, segments, teams, users) to source projection options from globalOptions, and updates the event command to format timestamps consistently. The infrastructure includes validation to enforce mutual exclusivity between --show-only and --show/--exclude, and a helper function to append field-projection usage hints to command help text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • absmartly/cli-ts#45: Modifies src/commands/events/index.ts and event output formatting for json-values/json-layouts around globalOptions.raw, sharing code-level changes to event command rendering paths.

Poem

🐰 Behold the grand refactor, fields now global, oh what a sight!
Once scattered across commands, now unified in flight.
Show, exclude, and showOnly dance at the root with grace,
Projecting data cleanly, leaving redundancy no place!
Version 1.11 hops forth, cleaner and more bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the two main changes: localizing event timestamps and promoting field-projection flags to global scope, with clear reference to the associated ticket.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/global-field-projection

Comment @coderabbitai help to get the list of available commands and usage tips.

@joalves joalves changed the title feat(cli): localize event timestamps and make --show/--exclude/--show-only global feat(cli): localize event timestamps and make --show/--exclude/--show-only global (FT-1979) Jun 1, 2026
@joalves joalves added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit aa29093 Jun 1, 2026
5 checks passed
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