Skip to content

refactor(time-range): parse --period at flag level via parsePeriod#760

Merged
BYK merged 2 commits intomainfrom
refactor/period-flag-parse
Apr 15, 2026
Merged

refactor(time-range): parse --period at flag level via parsePeriod#760
BYK merged 2 commits intomainfrom
refactor/period-flag-parse

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 15, 2026

Summary

Changes

Foundation (src/lib/time-range.ts):

  • formatTimeRangeFlag(range) — converts TimeRange back to CLI-friendly string for hints
  • TIME_RANGE_14D, TIME_RANGE_24H, TIME_RANGE_30D — pre-parsed constants for runtime defaults

Shared flag (src/lib/list-command.ts):

  • LIST_PERIOD_FLAG.parse: StringparsePeriod

8 commands updated (removed manual parsePeriod() calls):

Command Change
trace list, span list Use LIST_PERIOD_FLAG (already updated), remove parsePeriod import
event list, issue events Same (via shared-events.ts)
issue list Inline flag: parse: parsePeriod, remove redundant ?? DEFAULT_PERIOD
trace logs Inline flag: parse: parsePeriod
log list optional: true, runtime default via TIME_RANGE_14D/TIME_RANGE_30D
dashboard view optional: true, runtime default via parsePeriod(dashboard.period) + TIME_RANGE_24H

Excluded: release list — passes flags.period as raw statsPeriod string to the API.

Move parsePeriod into the Stricli flag parse function on all --period
definitions. flags.period is now TimeRange instead of string — commands
no longer call parsePeriod() manually. Invalid periods are rejected at
parse time, before func() runs.

- LIST_PERIOD_FLAG: parse: String → parse: parsePeriod
- 6 commands: remove parsePeriod() call, use flags.period directly
- 2 optional-flag commands (log list, dashboard view): use pre-parsed
  TimeRange constants for runtime defaults
- Add formatTimeRangeFlag() for hint builders that need the string form
- Add TIME_RANGE_14D/24H/30D constants for common defaults
- release list excluded (raw statsPeriod passthrough)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (init) Pre-supply existingSentry to eliminate roundtrip by betegon in #755

Bug Fixes 🐛

  • (arg-parsing) Normalize spaces in slugs and trim whitespace in issue IDs (CLI-14M, CLI-16M) by BYK in #757
  • (search) Rewrite OR queries to in-list syntax across all --query commands (CLI-16J) by BYK in #758
  • (upgrade) Retry spawn on EBUSY for Windows Defender file locking (CLI-16E) by BYK in #756

Internal Changes 🔧

  • (time-range) Parse --period at flag level via parsePeriod by BYK in #760
  • Regenerate docs by github-actions[bot] in 34bf056d

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-760/

Built to branch gh-pages at 2026-04-15 22:07 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 82.76%. Project has 1632 uncovered lines.
❌ Project coverage is 95.46%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/time-range.ts 72.22% ⚠️ 10 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.48%    95.46%    -0.02%
==========================================
  Files          236       236         —
  Lines        35898     35924       +26
  Branches         0         0         —
==========================================
+ Hits         34273     34292       +19
- Misses        1625      1632        +7
- Partials         0         0         —

Generated by Codecov Action

Comment thread src/commands/issue/list.ts Outdated
Replace the repeated formatTimeRangeFlag + comparison + push pattern
in 4 hint builders with a shared appendPeriodHint() helper. Fix the
hardcoded '90d' literal in issue/list.ts to use DEFAULT_PERIOD.
@BYK BYK merged commit 0258b03 into main Apr 15, 2026
26 checks passed
@BYK BYK deleted the refactor/period-flag-parse branch April 15, 2026 22:17
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