Skip to content

add pager to atmos describe stack command#1265

Merged
Benbentwo merged 143 commits intomainfrom
feature/dev-3221-add-pager-to-atmos-describe-stack-command
Jun 5, 2025
Merged

add pager to atmos describe stack command#1265
Benbentwo merged 143 commits intomainfrom
feature/dev-3221-add-pager-to-atmos-describe-stack-command

Conversation

@samtholiya
Copy link
Collaborator

@samtholiya samtholiya commented May 22, 2025

what

  • we adding pager capability to atmos describe stack command.
    image

why

  • This will give users a better view of the content.

references

Summary by CodeRabbit

  • Refactor

    • Improved the structure and modularity of the "describe stacks" command, separating command-line parsing, validation, and execution logic for better maintainability.
    • Introduced clearer error handling and validation for command options.
    • Enhanced internal interfaces to support more flexible testing and execution.
    • Renamed and clarified flag handling functions for affected commands.
  • Tests

    • Added comprehensive unit tests for the "describe stacks" command and its argument parsing.
    • Updated and improved test coverage for command execution logic.
    • Introduced mocks for execution interfaces to facilitate testing.

samtholiya and others added 30 commits April 14, 2025 23:21
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Base automatically changed from feature/dev-3182-add-pager-to-atmos-describe-affected-command to main June 3, 2025 19:59
@mergify mergify bot removed the stacked label Jun 3, 2025
@mergify
Copy link

mergify bot commented Jun 3, 2025

💥 This pull request now has conflicts. Could you fix it @samtholiya? 🙏

@mergify mergify bot added the conflict This PR has conflicts label Jun 3, 2025
@github-actions github-actions bot added the size/l label Jun 3, 2025
@mergify mergify bot removed the conflict This PR has conflicts label Jun 3, 2025
@samtholiya samtholiya added the minor New features that do not break anything label Jun 3, 2025
tt.setFlags(fs)

// Call the function
if tt.expectedPanic {

Check warning

Code scanning / golangci-lint

if tt.expectedPanic has complex nested blocks (complexity: 4) Warning test

if tt.expectedPanic has complex nested blocks (complexity: 4)
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

📝 Walkthrough

Walkthrough

This update refactors the describe_stacks command to use a new argument struct and execution interface, modularizes CLI flag parsing, and introduces targeted unit tests and mocks. It also renames a flag-parsing function for describe_affected for clarity, with corresponding test updates. No business logic is changed.

Changes

File(s) Change Summary
cmd/describe_affected.go, cmd/describe_affected_test.go Renamed function setFlagValueInCliArgs to setDescribeAffectedFlagValueInCliArgs and updated test calls accordingly.
cmd/describe_stacks.go Refactored command execution to use dependency-injected runnable, modularized CLI flag parsing into setCliArgsForDescribeStackCli, added error handling helper, and updated imports.
cmd/describe_stacks_test.go Added unit tests for the new runnable and CLI argument parsing logic, including error and panic scenarios.
internal/exec/describe_stacks.go Replaced monolithic command function with DescribeStacksArgs struct, DescribeStacksExec interface, and implementation; removed direct CLI dependency.
internal/exec/describe_stacks_test.go Replaced CLI-based test with direct unit test for the new execution struct using mocks.
internal/exec/mock_describe_stacks.go Added GoMock-generated mock for the DescribeStacksExec interface.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant FlagParser
    participant DescribeStacksExec
    participant Output

    User->>CLI: Run "describe stacks" command
    CLI->>FlagParser: Parse CLI flags
    FlagParser->>CLI: Return DescribeStacksArgs
    CLI->>DescribeStacksExec: Execute(args, config)
    DescribeStacksExec->>Output: Render results (with paging/format)
    Output-->>User: Show results
Loading

Possibly related PRs

Suggested reviewers

  • osterman
  • aknysh

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1) <title>502 Server Error</title>

Error: Server Error

The server encountered a temporary error and could not complete your request.

Please try again in 30 seconds.


📜 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 1f4b159 and 9a76db8.

📒 Files selected for processing (5)
  • cmd/describe_stacks.go (2 hunks)
  • cmd/describe_stacks_test.go (1 hunks)
  • internal/exec/describe_stacks.go (1 hunks)
  • internal/exec/describe_stacks_test.go (1 hunks)
  • internal/exec/mock_describe_stacks.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/exec/mock_describe_stacks.go
  • internal/exec/describe_stacks.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/exec/describe_stacks_test.go (3)
pkg/pager/mock_pager.go (1)
  • NewMockPageCreator (25-29)
pkg/schema/schema.go (1)
  • AtmosConfiguration (23-57)
internal/exec/describe_stacks.go (1)
  • DescribeStacksArgs (17-30)
🪛 golangci-lint (1.64.8)
cmd/describe_stacks_test.go

[warning] 108-108: if tt.expectedPanic has complex nested blocks (complexity: 4)

(nestif)

🪛 GitHub Check: golangci-lint
cmd/describe_stacks_test.go

[warning] 108-108:
if tt.expectedPanic has complex nested blocks (complexity: 4)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (6)
internal/exec/describe_stacks_test.go (1)

12-30: Clean test refactoring with proper mocking.

The refactored test effectively isolates the execution logic from CLI concerns using well-structured mocks. This approach provides better test coverage of the core functionality without the complexity of command-line parsing.

cmd/describe_stacks_test.go (3)

15-37: Good test coverage for runnable command generation.

The test properly verifies that the mock execution function is called exactly once, ensuring the command wiring works correctly.


39-86: Comprehensive table-driven tests for CLI argument parsing.

The test cases cover various scenarios including flag combinations, defaults, and explicit settings. This provides solid coverage for the argument parsing logic.


127-161: Direct panic testing approach works well.

The separate test case for unsupported flag types effectively validates the error handling without adding complexity to the table-driven tests.

cmd/describe_stacks.go (2)

22-29: Excellent dependency injection approach.

The higher-order function pattern with explicit dependencies makes the command much more testable and modular.


65-69: Good error handling centralization.

The extracted printErrorAndExit function provides consistent error handling across the command execution flow.

✨ Finishing Touches
  • 📝 Generate Docstrings

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 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]
coderabbitai bot previously approved these changes Jun 3, 2025
@mergify mergify bot removed the triage Needs triage label Jun 3, 2025
@samtholiya samtholiya force-pushed the feature/dev-3221-add-pager-to-atmos-describe-stack-command branch from c67e305 to 50daec2 Compare June 3, 2025 20:34
@Benbentwo Benbentwo merged commit 8957ff6 into main Jun 5, 2025
82 of 83 checks passed
@Benbentwo Benbentwo deleted the feature/dev-3221-add-pager-to-atmos-describe-stack-command branch June 5, 2025 17:08
@coderabbitai coderabbitai bot mentioned this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants