Repository navigation
update help with pager - #1276
Conversation
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughThis 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
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
Assessment against linked issues: Out-of-scope changes
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
pkg/pager/term_size.go (1)
131-172: ANSI sequence parsing is thorough but complex.The ANSI sequence handling covers the main cases (CSI sequences, character sets). The logic appears correct for skipping these non-printable sequences.
Note: Static analysis flagged the cyclomatic complexity of
skipAnsiSequence(15 > 10). While the current implementation works, the complexity stems from the nested conditions and could potentially be simplified with a state machine approach if this becomes a maintenance concern.
🧹 Nitpick comments (2)
cmd/root.go (1)
251-259: Smart conditional logic for TTY detection.The buffering approach with TTY detection is well thought out. However, consider simplifying the conditional logic for better readability.
Consider extracting this logic into a helper function:
+func printStyledAtmosHeader(command *cobra.Command, buf *bytes.Buffer) error { + if term.IsTTYSupportForStdout() { + return tuiUtils.PrintStyledTextToSpecifiedOutput(buf, "ATMOS") + } + return tuiUtils.PrintStyledText("ATMOS") +} + // In the help function: - if term.IsTTYSupportForStdout() { - err = tuiUtils.PrintStyledTextToSpecifiedOutput(&buf, "ATMOS") - } else { - err = tuiUtils.PrintStyledText("ATMOS") - } + err = printStyledAtmosHeader(command, &buf)🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 251-259: cmd/root.go#L251-L259
Added lines #L251 - L259 were not covered by testspkg/pager/term_size.go (1)
63-90: Solid content fitting logic with room for enhancement.The core logic correctly checks both height and width constraints. The approach of measuring actual display width (accounting for tabs and ANSI sequences) is thorough.
Consider whether the height check should be slightly more conservative - you might want to reserve a line or two for shell prompts or status information.
- // Check height: number of lines should not exceed terminal height - if len(lines) > termSize.Height { + // Check height: number of lines should not exceed terminal height (reserve 1 line for prompt) + if len(lines) >= termSize.Height { return false }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
cmd/root.go(3 hunks)internal/tui/utils/utils.go(2 hunks)pkg/pager/pager.go(2 hunks)pkg/pager/term_size.go(1 hunks)pkg/pager/term_size_test.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
pkg/pager/term_size_test.go (2)
pkg/pager/term_size.go (2)
MockTerminalSizer(35-39)ContentFitsTerminal(64-90)pkg/pager/pager.go (1)
New(22-28)
🪛 GitHub Check: codecov/patch
cmd/root.go
[warning] 251-259: cmd/root.go#L251-L259
Added lines #L251 - L259 were not covered by tests
[warning] 266-270: cmd/root.go#L266-L270
Added lines #L266 - L270 were not covered by tests
[warning] 272-272: cmd/root.go#L272
Added line #L272 was not covered by tests
internal/tui/utils/utils.go
[warning] 37-38: internal/tui/utils/utils.go#L37-L38
Added lines #L37 - L38 were not covered by tests
pkg/pager/pager.go
[warning] 31-34: pkg/pager/pager.go#L31-L34
Added lines #L31 - L34 were not covered by tests
[warning] 36-52: pkg/pager/pager.go#L36-L52
Added lines #L36 - L52 were not covered by tests
pkg/pager/term_size.go
[warning] 30-31: pkg/pager/term_size.go#L30-L31
Added lines #L30 - L31 were not covered by tests
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Summary
🔇 Additional comments (17)
internal/tui/utils/utils.go (1)
6-6: Good addition for the new functionality.The
ioimport supports the new generalized function nicely.cmd/root.go (2)
4-4: Imports look appropriate for the new functionality.The new imports support the pager integration and terminal detection features nicely.
Also applies to: 20-20, 24-24
272-272: Consistent formatting with the conditional branch.Good consistency in adding the newline for both help scenarios.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 272-272: cmd/root.go#L272
Added line #L272 was not covered by testspkg/pager/pager.go (4)
4-4: Appropriate imports for the new functionality.The fmt and term imports support the enhanced pager logic effectively.
Also applies to: 8-8
17-19: Excellent design for testability.Adding function fields to the struct enables easy mocking and testing. This is a solid architectural choice.
24-26: Clean dependency injection in constructor.The initialization properly wires up the dependencies for the enhanced functionality.
31-34: Smart early return for non-TTY environments.The TTY check prevents unnecessary pager activation in non-interactive environments. This is exactly the right behavior.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 31-34: pkg/pager/pager.go#L31-L34
Added lines #L31 - L34 were not covered by testspkg/pager/term_size_test.go (7)
1-8: Well-structured test package setup.The imports and package declaration are clean and appropriate for the testing needs.
9-57: Comprehensive test coverage for terminal size functionality.The test cases cover the essential scenarios including success, error handling, and edge cases like large dimensions. The mock usage with proper cleanup is excellent.
59-162: Thorough content fitting tests with diverse scenarios.The test cases effectively cover various content types, terminal sizes, and edge cases. The inclusion of ANSI sequence and tab handling tests is particularly valuable.
164-203: Excellent table-driven tests for display width calculation.The comprehensive test cases cover all the important scenarios including Unicode, ANSI sequences, control characters, and tab handling. This ensures robust width calculation.
205-267: Solid ANSI sequence handling tests.The tests thoroughly cover various ANSI escape sequences and edge cases. The separate edge case tests provide additional confidence in the implementation.
269-299: Smart inclusion of performance benchmarks.The benchmark tests provide valuable performance insights for both individual functions and realistic content scenarios.
301-334: Realistic integration test with practical scenarios.The integration test covers real-world content types and provides confidence that the entire system works together properly.
pkg/pager/term_size.go (3)
16-20: Well-structured type definition.The
TermSizestruct is clean and serves its purpose well for representing terminal dimensions.
22-32: Good use of dependency injection for testability.The interface pattern here enables clean testing. However, there's a test coverage gap for the real implementation.
The static analysis correctly identifies that lines 30-31 aren't covered by tests. While this is expected since it's a thin wrapper around the system call, consider adding an integration test to ensure the real terminal sizer works in actual terminal environments.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 30-31: pkg/pager/term_size.go#L30-L31
Added lines #L30 - L31 were not covered by tests
92-129: Comprehensive display width calculation with proper ANSI handling.The implementation correctly handles tabs, carriage returns, and ANSI escape sequences. The tab alignment calculation is mathematically sound, and the Unicode fallback is reasonable.
33dbccc to
6cb2111
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
pkg/pager/pager_test.go (1)
49-49: Address comment formatting for consistency.Based on the past review comments, ensure comments end with periods for consistency with your coding standards.
- // Track whether newTeaProgram was called and capture the model + // Track whether newTeaProgram was called and capture the model.Apply similar changes to other comments throughout the file.
Also applies to: 120-120, 175-175
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/pager/pager_test.go(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: [localstack] demo-localstack
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: Summary
🔇 Additional comments (8)
pkg/pager/pager_test.go (8)
1-9: Solid foundation with appropriate testing dependencies.Clean package structure with well-chosen imports for comprehensive testing.
11-45: Excellent table-driven test design covering key scenarios.The test cases comprehensively cover the decision matrix: TTY support vs content fitting. Good use of descriptive test names and clear expected behaviors.
47-102: Robust mocking approach with thorough verification.The dependency injection pattern allows for precise control over test conditions. The assertions properly verify both the decision logic and the model initialization details.
104-117: Clean helper model implementation.Simple and focused test double that serves its purpose well.
143-158: Straightforward error test model.Simple implementation that serves the testing needs adequately.
160-172: Constructor verification with appropriate type checking.Good verification that the constructor properly initializes all function dependencies. The type assertion approach works well in the test context.
174-211: Thorough model initialization verification.Excellent detailed checking of model state and viewport initialization. The assertions ensure the model is properly constructed with expected defaults.
213-254: Comprehensive coverage of non-pager scenarios.Well-structured test ensuring the pager is correctly bypassed when conditions don't require it. Good use of table-driven approach for different condition combinations.
7ac5b93 to
fc96258
Compare
Docstrings generation was requested by @samtholiya. * #1276 (comment) The following files were modified: * `cmd/root.go` * `internal/tui/utils/utils.go` * `pkg/pager/pager.go` * `pkg/pager/term_size.go`
|
Ben (@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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/pager/pager.go (1)
23-27: Consider a cleaner constructor pattern.The type assertion approach works but feels brittle. Consider making the constructor more explicit:
-func NewWithAtmosConfig(enablePager bool) PageCreator { - pager := New() - pager.(*pageCreator).enablePager = enablePager - return pager -} +func NewWithAtmosConfig(enablePager bool) PageCreator { + return &pageCreator{ + enablePager: enablePager, + newTeaProgram: tea.NewProgram, + contentFitsTerminal: ContentFitsTerminal, + isTTYSupportForStdout: term.IsTTYSupportForStdout, + } +}
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cmd/root.go(3 hunks)pkg/pager/pager.go(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- cmd/root.go
🧰 Additional context used
📓 Path-based instructions (1)
`pkg/*/*.go`: Organize feature implementations in subdirectories under pkg/ with separate files for each feature.
pkg/*/*.go: Organize feature implementations in subdirectories under pkg/ with separate files for each feature.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/atmos-rules.mdc)
List of files the instruction was applied to:
pkg/pager/pager.go
🧠 Learnings (2)
📓 Common learnings
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Learnt from: samtholiya
PR: cloudposse/atmos#955
File: tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden:0-0
Timestamp: 2025-01-19T15:49:15.593Z
Learning: In future commits, the help text for Atmos CLI commands should be limited to only show component and stack parameters for commands that actually use them. This applies to the example usage section in command help text.
Learnt from: Listener430
PR: cloudposse/atmos#934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: RoseSecurity
PR: cloudposse/atmos#757
File: cmd/docs.go:52-54
Timestamp: 2024-11-01T14:45:32.417Z
Learning: In `cmd/docs.go`, capping the terminal width at 120 columns is considered acceptable and preferred after testing.
pkg/pager/pager.go (13)
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected.go:122-123
Timestamp: 2025-05-22T19:58:32.988Z
Learning: The "pager" flag is defined as a PersistentFlag at the describe command level in cmd/describe.go, making it available to all subcommands including describeAffectedCmd without needing to redeclare it.
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: All pull requests must pass CI checks, which should run unit tests, integration tests, golangci-lint, and coverage reporting.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Before submitting a pull request, ensure all tests pass, code coverage meets targets, golangci-lint issues are fixed, and documentation is updated as needed.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Every new feature must include comprehensive unit tests, targeting over 80% code coverage for all packages, and tests should cover both happy paths and error conditions.
Learnt from: osterman
PR: cloudposse/atmos#727
File: internal/exec/terraform.go:114-118
Timestamp: 2024-10-21T17:51:07.087Z
Learning: Use `bubbletea` for confirmation prompts instead of `fmt.Scanln` in the `atmos terraform clean` command.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Use interfaces for external dependencies to facilitate mocking, and consider using testify/mock for creating mock implementations.
Learnt from: Listener430
PR: cloudposse/atmos#934
File: internal/exec/template_utils.go:268-271
Timestamp: 2025-01-25T03:49:03.951Z
Learning: The `ProcessTmplWithDatasourcesGomplate` function in `internal/exec/template_utils.go` is used for documentation generation purposes, where simple environment variable handling is acceptable and thread-safety concerns are not critical.
Learnt from: RoseSecurity
PR: cloudposse/atmos#757
File: cmd/docs.go:52-54
Timestamp: 2024-11-01T14:45:32.417Z
Learning: In `cmd/docs.go`, capping the terminal width at 120 columns is considered acceptable and preferred after testing.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Use table-driven tests in Go for testing multiple scenarios efficiently.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Follow Go's error handling idioms: use meaningful error messages, wrap errors with context using fmt.Errorf("context: %w", err), and consider custom error types for domain-specific errors.
🧬 Code Graph Analysis (1)
pkg/pager/pager.go (2)
pkg/pager/term_size.go (1)
ContentFitsTerminal(64-90)internal/tui/templates/term/term_writer.go (1)
IsTTYSupportForStdout(83-87)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Summary
🔇 Additional comments (3)
pkg/pager/pager.go (3)
17-21: Well-designed dependency injection for testability.The function fields approach enables clean mocking and testing of the pager logic without requiring complex setup or external dependencies.
38-41: Solid early exit strategy.The combined condition efficiently handles both disabled pager and non-TTY environments by falling back to direct output.
43-60: Smart content-aware paging logic.The conditional approach properly handles the common case where content fits the terminal without unnecessary pager overhead. The fallback to direct printing maintains good user experience.
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
pkg/pager/pager_test.go (1)
120-142: Test logic inconsistency needs clarification.The test name suggests error handling, but line 141 expects no error. The comment acknowledges that
tea.Program.Run()handles model errors internally, making this test's purpose unclear.
🧹 Nitpick comments (1)
pkg/pager/pager_test.go (1)
238-238: Fix misleading comment.The comment states "Disable pager to test direct printing" but
enablePageris set totrue.- enablePager: true, // Disable pager to test direct printing + enablePager: true, // Enable pager but other conditions prevent its use
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/pager/pager_test.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`pkg/*/*.go`: Organize feature implementations in subdirectories under pkg/ with separate files for each feature.
pkg/*/*.go: Organize feature implementations in subdirectories under pkg/ with separate files for each feature.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/atmos-rules.mdc)
List of files the instruction was applied to:
pkg/pager/pager_test.go
`pkg/*/*_test.go`: Include comprehensive unit tests for each feature in corresponding *_test.go files.
pkg/*/*_test.go: Include comprehensive unit tests for each feature in corresponding *_test.go files.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/atmos-rules.mdc)
List of files the instruction was applied to:
pkg/pager/pager_test.go
🧠 Learnings (2)
📓 Common learnings
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Learnt from: samtholiya
PR: cloudposse/atmos#955
File: tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden:0-0
Timestamp: 2025-01-19T15:49:15.593Z
Learning: In future commits, the help text for Atmos CLI commands should be limited to only show component and stack parameters for commands that actually use them. This applies to the example usage section in command help text.
Learnt from: Listener430
PR: cloudposse/atmos#934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: Listener430
PR: cloudposse/atmos#825
File: internal/exec/helmfile_generate_varfile.go:28-31
Timestamp: 2024-12-07T16:16:13.038Z
Learning: In `internal/exec/helmfile_generate_varfile.go`, the `--help` command (`./atmos helmfile generate varfile --help`) works correctly without requiring stack configurations, and the only change needed was to make `ProcessCommandLineArgs` exportable by capitalizing its name.
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected.go:122-123
Timestamp: 2025-05-22T19:58:32.988Z
Learning: The "pager" flag is defined as a PersistentFlag at the describe command level in cmd/describe.go, making it available to all subcommands including describeAffectedCmd without needing to redeclare it.
Learnt from: RoseSecurity
PR: cloudposse/atmos#757
File: cmd/docs.go:52-54
Timestamp: 2024-11-01T14:45:32.417Z
Learning: In `cmd/docs.go`, capping the terminal width at 120 columns is considered acceptable and preferred after testing.
pkg/pager/pager_test.go (17)
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Use table-driven tests in Go for testing multiple scenarios efficiently.
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Every new feature must include comprehensive unit tests, targeting over 80% code coverage for all packages, and tests should cover both happy paths and error conditions.
Learnt from: samtholiya
PR: cloudposse/atmos#1068
File: tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden:59-64
Timestamp: 2025-02-18T13:13:11.497Z
Learning: For Atmos CLI help text, angle brackets in command examples and flag descriptions should be escaped using HTML entities (e.g., `<component>`) rather than converted to backticks or other markdown formatting.
Learnt from: osterman
PR: cloudposse/atmos#768
File: internal/exec/vendor_utils.go:496-513
Timestamp: 2024-11-22T12:38:33.132Z
Learning: In the Atmos project, continue to flag path traversal issues in code reviews but acknowledge when they are expected and acceptable in specific cases.
Learnt from: samtholiya
PR: cloudposse/atmos#955
File: tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden:0-0
Timestamp: 2025-01-19T15:49:15.593Z
Learning: In future commits, the help text for Atmos CLI commands should be limited to only show component and stack parameters for commands that actually use them. This applies to the example usage section in command help text.
Learnt from: aknysh
PR: cloudposse/atmos#1185
File: internal/exec/yaml_func_store.go:26-26
Timestamp: 2025-04-04T02:03:23.676Z
Learning: The Atmos codebase currently uses `log.Fatal` for error handling in multiple places. The maintainers are aware this isn't an ideal pattern (should only be used in main() or init() functions) and plan to address it comprehensively in a separate PR. CodeRabbit should not flag these issues or push for immediate changes until that refactoring is complete.
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Learnt from: samtholiya
PR: cloudposse/atmos#896
File: cmd/editor_config.go:37-40
Timestamp: 2025-01-07T20:38:09.618Z
Learning: Error handling suggestion for `cmd.Help()` in `cmd/editor_config.go` was deferred as the code is planned for future modifications.
Learnt from: aknysh
PR: cloudposse/atmos#1185
File: internal/exec/yaml_func_store.go:71-72
Timestamp: 2025-04-04T02:03:21.906Z
Learning: The codebase currently uses `log.Fatal` for error handling in library functions, which terminates the program. There is a plan to refactor this approach in a separate PR to improve API design by returning error messages instead of terminating execution.
Learnt from: milldr
PR: cloudposse/atmos#1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning the error instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Follow Go's error handling idioms: use meaningful error messages, wrap errors with context using fmt.Errorf("context: %w", err), and consider custom error types for domain-specific errors.
Learnt from: milldr
PR: cloudposse/atmos#1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning specific error variables (like `ErrWorkflowNoSteps`, `ErrInvalidFromStep`, `ErrInvalidWorkflowStepType`, `ErrWorkflowStepFailed`) instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions while maintaining excellent user-facing error formatting.
Learnt from: samtholiya
PR: cloudposse/atmos#959
File: cmd/describe_config.go:20-20
Timestamp: 2025-02-03T06:00:11.419Z
Learning: Commands should use `PrintErrorMarkdownAndExit` with empty title and suggestion (`"", err, ""`) for general error handling. Specific titles like "Invalid Usage" or "File Not Found" should only be used for validation or specific error scenarios.
Learnt from: osterman
PR: cloudposse/atmos#715
File: pkg/logger/logger.go:21-32
Timestamp: 2024-10-12T18:38:28.458Z
Learning: In Go code, avoid prefixing struct names with 'I' (e.g., `IError`) as it can be confusing, suggesting an interface. Use descriptive names for structs to improve code clarity.
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: The atmos codebase has a custom extension to *testing.T that provides a Chdir method, allowing test functions to call t.Chdir() to change working directories during tests. This is used consistently across test files in the codebase.
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-06-23T12:28:41.880Z
Learning: Use interfaces for external dependencies to facilitate mocking, and consider using testify/mock for creating mock implementations.
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Summary
🔇 Additional comments (5)
pkg/pager/pager_test.go (5)
11-103: Solid table-driven test implementation.The test structure follows Go best practices effectively. The mocking approach for dependencies is clean and the test scenarios cover the key behavioral paths.
105-118: Well-designed test helper.The
simpleTestModelprovides a minimal, focused implementation for testing without unnecessary complexity.
161-173: Good constructor validation.The test properly verifies that
New()returns a correctly initializedpageCreatorwith all required function fields populated.
175-212: Thorough model creation verification.Nice detailed testing of the model initialization, including viewport state and program options.
214-256: Comprehensive coverage of non-pager scenarios.Good testing of the conditions where the pager should be bypassed. The test cases cover both TTY and content fitting scenarios appropriately.
* update help with pager * [autofix.ci] apply automated fixes * fix linting issues * fix test cases * fix golanglint * fix golang lint * fix test cases * add pager test * try to fix pager tests * add pager env support * pager updated * pager test * update test --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Andriy Knysh <[email protected]>
|
These changes were released in v1.182.0. |
what
why
references
Summary by CodeRabbit
New Features
Bug Fixes
Tests