atmos icon indicating copy to clipboard operation
atmos copied to clipboard

update help with pager

Open samtholiya opened this issue 9 months ago โ€ข 5 comments

what

  • Updated help with pager image

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.

samtholiya avatar May 31 '25 22:05 samtholiya

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.

Files with missing lines Patch % Lines
cmd/root.go 0.00% 15 Missing :warning:
pkg/pager/pager.go 75.86% 6 Missing and 1 partial :warning:
internal/tui/utils/utils.go 0.00% 2 Missing :warning:
pkg/pager/term_size.go 97.91% 2 Missing :warning:
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.

codecov[bot] avatar Jun 01 '25 14:06 codecov[bot]

๐Ÿ“ 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.

โค๏ธ Share
๐Ÿชง 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere 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.

coderabbitai[bot] avatar Jun 01 '25 15:06 coderabbitai[bot]

[!NOTE] Generated docstrings for this pull request at https://github.com/cloudposse/atmos/pull/1299

coderabbitai[bot] avatar Jun 13 '25 19:06 coderabbitai[bot]

Not seeing the pager working on help anymore, looks like --pager flag doesn't work on help

Benbentwo avatar Jun 24 '25 15:06 Benbentwo

@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

samtholiya avatar Jun 26 '25 21:06 samtholiya

These changes were released in v1.182.0.

github-actions[bot] avatar Jul 01 '25 03:07 github-actions[bot]