-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom help message and upgrade notification #809
base: main
Are you sure you want to change the base?
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces enhancements to the command processing functionality within the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
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)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
cmd/root.go (1)
72-78
: Consider consolidating help function implementations.There are now multiple help function implementations in the file (see
initConfig()
). Consider consolidating these to maintain a single source of truth for help functionality.Suggestions:
- Move all help-related logic to a dedicated helper
- Ensure the styled Atmos logo is consistently displayed
- Consider creating a chain of responsibility for help message components
cmd/cmd_utils.go (1)
477-484
: Consider using semantic versioning for version comparisonDirect string comparison of versions might not accurately reflect actual version precedence, especially with multi-digit numbers. Using a semantic versioning library can provide more reliable comparisons between
latestRelease
andcurrentRelease
.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
cmd/cmd_utils.go
(4 hunks)cmd/root.go
(1 hunks)
🔇 Additional comments (3)
cmd/root.go (1)
76-78
: Verify the custom help message implementation.
The integration looks solid, but let's verify the custom help message implementation.
✅ Verification successful
Custom help message implementation is well-structured and complete
The implementation is solid and includes:
- Proper preservation of original help functionality
- Clean version comparison logic
- Well-formatted upgrade message with:
- Color-coded borders and text
- Centered content with proper padding
- Helpful links to releases and installation guide
- Clear version information display
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the custom help message function implementation
# Check for the function definition
ast-grep --pattern 'func customHelpMessageToUpgradeToAtmosLatestRelease($_, $_) {
$$$
}'
# Check for any related test files
fd -e go -e test test_.*root
Length of output: 895
Script:
#!/bin/bash
# Let's verify the complete implementation by checking related functions and tests
# Check for the original help function declaration
ast-grep --pattern 'originalHelpFunc := $_'
# Check the upgrade message printing function
ast-grep --pattern 'func printMessageToUpgradeToAtmosLatestRelease($_) {
$$$
}'
# Search for any test files that might cover this functionality
rg -l "customHelpMessageToUpgradeToAtmosLatestRelease" --type go
Length of output: 2202
cmd/cmd_utils.go (2)
466-471
: Verify stripANSI
handles all ANSI escape codes
The regular expression in stripANSI
may not cover all ANSI escape sequences. Please confirm that it effectively removes all types of ANSI codes to ensure clean message output.
432-464
: The bordered upgrade message is well-crafted
The implementation for displaying the bordered upgrade notification looks solid and should enhance user awareness.
eeb83db
to
be49831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
cmd/root.go (1)
Line range hint
143-160
: HARK! Multiple help function configurations detected!Brave warrior, I notice that
initConfig()
also sets a help function. This could potentially conflict with our new implementation inExecute()
. Consider:
- Consolidating the help function setup into one location
- Ensuring the styled logo printing is preserved
Consider refactoring to combine these help function configurations:
func initConfig() { styles := boa.DefaultStyles() b := boa.New(boa.WithStyles(styles)) RootCmd.SetUsageFunc(b.UsageFunc) - RootCmd.SetHelpFunc(func(command *cobra.Command, strings []string) { - // Print a styled Atmos logo to the terminal - fmt.Println() - err := tuiUtils.PrintStyledText("ATMOS") - if err != nil { - u.LogErrorAndExit(schema.CliConfiguration{}, err) - } - b.HelpFunc(command, strings) - command.Usage() - }) }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
cmd/cmd_utils.go
(3 hunks)cmd/root.go
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- cmd/cmd_utils.go
🔇 Additional comments (2)
cmd/root.go (2)
21-22
: VICTORY! The variable declaration is now properly implemented!
The addition of originalHelpFunc
with its documentation is a worthy improvement to the codebase.
75-81
: By Zeus's beard, let's verify this help function integration!
The implementation looks solid, following the proper pattern of preserving the original help functionality. However, we should verify:
- The integration with
customHelpMessageToUpgradeToAtmosLatestRelease
- The proper chaining of help functions
Let's inspect the implementation:
✅ Verification successful
The previous results show multiple help function setups, and we need to verify the complete implementation of our custom help function to ensure it properly chains the original help function and adds the upgrade message without recursion. This will help us make a definitive assessment.
By the might of Ares, this help function implementation is battle-ready!
The implementation shows excellent discipline in preventing recursion and maintaining proper command chain:
- The
customHelpMessageToUpgradeToAtmosLatestRelease
function first callsoriginalHelpFunc(cmd, args)
, ensuring the original help content is displayed - It then checks for newer versions and only displays the upgrade message when a newer version exists
- The function properly avoids recursion by using the stored
originalHelpFunc
The implementation follows the warrior's path - clean, efficient, and purposeful. Your code stands strong, ready for battle! 🛡️
[category: help_functions, upgrade_notifications]
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the help function implementation and its usage
# Check the custom help function implementation
ast-grep --pattern 'func customHelpMessageToUpgradeToAtmosLatestRelease($cmd *cobra.Command, $args []string) {
$$$
}'
# Verify no direct recursion in help function calls
rg -A 5 'SetHelpFunc|HelpFunc'
Length of output: 2145
Script:
#!/bin/bash
# Let's check the complete implementation of customHelpMessageToUpgradeToAtmosLatestRelease
rg -A 15 "func customHelpMessageToUpgradeToAtmosLatestRelease"
# Also check for any other help function overrides in the codebase
ast-grep --pattern 'SetHelpFunc($$$)'
Length of output: 1012
what
This pull request enhances the atmos CLI by adding a bordered update notification message at the bottom of the help output for all commands, including atmos --help and subcommands like atmos terraform --help. The update notification informs users if a newer version of atmos is available
Befroe
After
final version
why
references
Linear issue https://linear.app/cloudposse/issue/DEV-2766/atmos-help-should-show-latest-version
Summary by CodeRabbit
Summary by CodeRabbit