update help with pager
what
- Updated help with pager
why
- Makes easier for users to view the content
references
Summary by CodeRabbit
-
New Features
- Enhanced help command output with improved formatting and paging for easier reading in the terminal.
- Help text now adapts to terminal size, displaying content directly or using a pager interface as needed.
- Added terminal size detection to optimize content display based on terminal dimensions.
- Introduced styled text output functions supporting flexible output destinations.
-
Bug Fixes
- More accurate handling of styled and colored text in terminal output.
-
Tests
- Added comprehensive tests for terminal size detection and content fitting logic to ensure reliable display behavior.
- Introduced tests covering pager behavior under various terminal conditions and error scenarios.
Codecov Report
Attention: Patch coverage is 81.69014% with 26 lines in your changes missing coverage. Please review.
Project coverage is 51.37%. Comparing base (
1a0fac2) to head (9c7dc69). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1276 +/- ##
==========================================
- Coverage 51.37% 51.37% -0.01%
==========================================
Files 243 244 +1
Lines 26295 26423 +128
==========================================
+ Hits 13510 13574 +64
- Misses 11114 11186 +72
+ Partials 1671 1663 -8
| Flag | Coverage ฮ | |
|---|---|---|
| unittests | 51.37% <81.69%> (-0.01%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
๐ Walkthrough
Walkthrough
This change introduces a terminal-aware pager for the help command. It detects if the output fits the terminal viewport and conditionally invokes a pager UI. Terminal size and content fitting logic are abstracted for extensibility and testability, with comprehensive tests for display width and ANSI sequence handling.
Changes
| File(s) | Change Summary |
|---|---|
| cmd/root.go | Refactored help command logic: buffers styled output, checks TTY, pipes help through pager, adds conditional formatting. |
| internal/tui/utils/utils.go | Added PrintStyledTextToSpecifiedOutput to write styled text to any io.Writer. |
| pkg/pager/pager.go | Added terminal fit and TTY detection to pager; bypasses pager UI if not needed; updated control flow. |
| pkg/pager/term_size.go | New file: Terminal size abstraction, content fitting logic, display width calculation, ANSI escape handling. |
| pkg/pager/term_size_test.go | New file: Unit and integration tests for terminal sizing, content fitting, display width, and ANSI handling. |
| pkg/pager/pager_test.go | New file: Unit tests for pager control flow, TTY detection, content fitting, and error handling. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant CLI
participant Pager
participant Terminal
User->>CLI: Run help command
CLI->>Terminal: Is stdout TTY?
alt Not TTY
CLI->>CLI: Print help output directly
else TTY
CLI->>Pager: Does content fit terminal?
alt Fits
CLI->>CLI: Print help output directly
else Does not fit
CLI->>Pager: Start pager UI
Pager->>User: Display paged help
end
end
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Add pager to help command, only load pager if content exceeds TTY height (DEV-3299) | โ | |
| Pager should support forcing color via config or ENV (DEV-3299) | โ | No explicit implementation for forced color observed. |
| Use bubbles go modules for pager (DEV-3299) | โ |
Assessment against linked issues: Out-of-scope changes
| Code Change | Explanation |
|---|---|
| None found |
Suggested reviewers
- Benbentwo
- aknysh
๐ Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between a5206bd5cbd100c49ce0720d8c42dd5bcdd45288 and b649f37dfdcc9ef061b7ff0d6dbc98027ae8e82b.
๐ Files selected for processing (1)
-
pkg/pager/pager_test.go(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- pkg/pager/pager_test.go
โฐ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Build (ubuntu-latest, linux)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Summary
โจ Finishing Touches
- [ ] ๐ Generate Docstrings
๐งช Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Post Copyable Unit Tests in Comment
- [ ] Commit Unit Tests in branch
feature/dev-3299-add-pager-to-help
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
๐ชง Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and explain its main purpose. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai auto-generate unit teststo generate unit tests for this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryor@auto-summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaior@auto-titleanywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
[!NOTE] Generated docstrings for this pull request at https://github.com/cloudposse/atmos/pull/1299
Not seeing the pager working on help anymore, looks like --pager flag doesn't work on help
@Benbentwo this is pager for help. We do not require pager flag here... help flag overrides every flag. And that should be by design.
I have added env support but that is all we should do
These changes were released in v1.182.0.