-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat(client): add auto cli for node service #21074
Conversation
WalkthroughWalkthroughThe recent changes introduce a new AutoCLI feature in the Cosmos SDK, enhancing the command-line interface for node services. This includes the implementation of commands for querying node configurations and statuses, improving usability for developers and users. The modifications seamlessly integrate these functionalities into the existing command structure, bolstering the SDK's capabilities while maintaining overall code organization. Changes
Assessment against linked issues
Possibly related issues
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Hi, nope currently that's just the way to do it. For instance check out https://github.com/cosmos/cosmos-sdk/blob/main/client/grpc/cmtservice/autocli.go AutoCLI has been made for module CLI in mind (for the detection), so best to just use this trick for now. |
Okay |
Actually a good place to put it is here: https://github.com/cosmos/cosmos-sdk/blob/main/x/consensus/autocli.go#L25-L27 |
Sorry for the delay
comet was added under the consensus CLI, but I’m not sure where to place the node CLI. |
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, codebase verification and nitpick comments (4)
client/grpc/node/autocli.go (2)
8-22
: Consider using a more descriptive variable name.The variable
ServiceAutoCLIDescriptor
could be more descriptive to indicate its purpose clearly, such asNodeServiceAutoCLIDescriptor
.
30-43
: Ensure interface conformity and consider documentation.The
nodeModule
struct and its methods appear to conform to an expected interface. Consider adding comments to clarify which interface is being implemented for better readability and maintenance.simapp/v2/simdv2/cmd/root_di.go (1)
87-90
: Consider error handling and documentation.While the integration of
nodeCmds
is correct, consider adding documentation to explain the purpose ofnodeCmds
and its impact on the root command. Additionally, ensure that any potential errors in command enhancement are properly handled.simapp/simd/cmd/root_di.go (1)
88-91
: Consider error handling and documentation.While the integration of
nodeCmds
is correct, consider adding documentation to explain the purpose ofnodeCmds
and its impact on the root command. Additionally, ensure that any potential errors in command enhancement are properly handled.
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (5)
- CHANGELOG.md (1 hunks)
- client/grpc/node/autocli.go (1 hunks)
- simapp/simd/cmd/root.go (2 hunks)
- simapp/simd/cmd/root_di.go (2 hunks)
- simapp/v2/simdv2/cmd/root_di.go (3 hunks)
Files skipped from review due to trivial changes (1)
- CHANGELOG.md
Additional context used
Path-based instructions (4)
client/grpc/node/autocli.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/v2/simdv2/cmd/root_di.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/simd/cmd/root_di.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/simd/cmd/root.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (5)
client/grpc/node/autocli.go (1)
24-28
: LGTM!The function
NewNodeCommands
is straightforward and conforms to the style guide.simapp/v2/simdv2/cmd/root_di.go (1)
Line range hint
6-23
: LGTM!The new imports for
autocliv1
andnodeservice
are necessary for the new functionality and conform to the style guide.simapp/simd/cmd/root_di.go (1)
8-9
: LGTM!The new imports for
autocliv1
andnodeservice
are necessary for the new functionality and conform to the style guide.simapp/simd/cmd/root.go (2)
9-9
: Confirm the necessity of thenodeservice
import.The
nodeservice
package is imported to add node commands. Ensure that this package is required and correctly used within the file.Verification successful
The
nodeservice
import is necessary and correctly used.The
nodeservice.NewNodeCommands
function is utilized in multiple files, includingsimapp/simd/cmd/root.go
, confirming the necessity and correctness of the import for adding node commands to the CLI.
- Files using
nodeservice.NewNodeCommands
:
simapp/v2/simdv2/cmd/root_di.go
simapp/simd/cmd/root.go
simapp/simd/cmd/root_di.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `nodeservice` package in the codebase. # Test: Search for the usage of `nodeservice.NewNodeCommands`. Expect: Occurrences in the codebase. rg --type go 'nodeservice.NewNodeCommands'Length of output: 254
126-128
: Ensure correct initialization and integration ofnodeCmds
.The
nodeCmds
variable is initialized and its options are added toautoCliOpts.ModuleOptions
. Verify that this integration aligns with the intended functionality and best practices.Verification successful
Verify the implementation of
NewNodeCommands
andAutoCLIOptions
.To ensure the correct initialization and integration of
nodeCmds
, verify the implementation ofNewNodeCommands
andAutoCLIOptions
in the codebase. This will confirm if they are correctly defined and used.
Investigate the definition of
nodeModule
to ensureAutoCLIOptions
is implemented.The
NewNodeCommands
function returns anodeModule
pointer, but theAutoCLIOptions
method implementation was not found. Check thenodeModule
struct or interface to verify ifAutoCLIOptions
is defined and correctly implemented.
Integration of
nodeCmds
is correctly implemented.The
nodeModule
struct and itsAutoCLIOptions
method are properly defined and implemented inclient/grpc/node/autocli.go
. This confirms that the integration ofnodeCmds
withautoCliOpts.ModuleOptions
is correct and aligns with the intended functionality.
nodeModule
struct is defined inclient/grpc/node/autocli.go
.AutoCLIOptions
method is implemented fornodeModule
in the same file.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `nodeCmds` in the codebase. # Test: Check if `nodeCmds.AutoCLIOptions()` is properly utilized. Expect: Proper integration in the command structure. rg --type go 'nodeCmds.AutoCLIOptions'Length of output: 337
Script:
#!/bin/bash # Find the implementation of `NewNodeCommands` in the codebase. ast-grep --lang go --pattern 'func NewNodeCommands() $_ { $$$ }' # Find the implementation of `AutoCLIOptions` method in the codebase. ast-grep --lang go --pattern 'func (n $_) AutoCLIOptions() $_ { $$$ }'Length of output: 293
Script:
#!/bin/bash # Search for the definition of `nodeModule` to check for `AutoCLIOptions` method. ast-grep --lang go --pattern 'type nodeModule struct { $$$ }' # Search for interfaces or methods related to `nodeModule` that might define `AutoCLIOptions`. rg --type go 'AutoCLIOptions'Length of output: 5684
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.
utACK
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, codebase verification and nitpick comments (1)
simapp/v2/simdv2/cmd/root_di.go (1)
87-89
: Enhancement of CLI with node commands looks good.The integration of
nodeCmds
intoautoCliOpts.ModuleOptions
effectively enhances the CLI functionalities. Consider adding comments to explain the purpose of these lines for improved readability.+ // Initialize node commands for CLI enhancements nodeCmds := nodeservice.NewNodeCommands() + // Populate ModuleOptions with node command AutoCLI options autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions) autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions()
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (3)
- simapp/simd/cmd/root.go (2 hunks)
- simapp/simd/cmd/root_di.go (3 hunks)
- simapp/v2/simdv2/cmd/root_di.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- simapp/simd/cmd/root.go
- simapp/simd/cmd/root_di.go
Additional context used
Path-based instructions (1)
simapp/v2/simdv2/cmd/root_di.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (2)
simapp/v2/simdv2/cmd/root_di.go (2)
8-8
: Importautocliv1
is appropriate.The addition of
autocliv1
is necessary for integrating automatic CLI options.
23-23
: Importnodeservice
is appropriate.The addition of
nodeservice
is necessary for node command functionalities.
(cherry picked from commit 1cb2336) # Conflicts: # CHANGELOG.md
Co-authored-by: zakir <[email protected]> Co-authored-by: Julien Robert <[email protected]>
* main: (76 commits) docs: more app v2 renaming (#21336) chore: update link in disclaimer (#21339) refactor(x/distribution): audit QA (#21316) docs: rename app v2 to app di when talking about runtime v0 (#21329) feat(schema): specify JSON mapping (#21243) fix(x/authz): bring back msg response in `DispatchActions` (#21044) chore: fix all lint issue since golangci-lint bump (#21326) refactor(x/mint): v0.52 audit x/mint (#21301) chore: fix spelling errors (#21327) feat: export genesis in simapp v2 (#21199) fix(baseapp)!: Halt at height now does not produce the halt height block (#21256) refactor(scripts): remove unused variable (#21320) chore(schema/testing): upgrade to go 1.23 iterators (#21282) chore: readmes + upgrading docs (#21271) feat(client): add auto cli for node service (#21074) ci: fix github workflow vulnerable to script injection (#21304) build(deps): Bump github.com/prometheus/client_golang from 1.19.1 to 1.20.0 (#21307) build(deps): use Go 1.23 instead of Go 1.22 (#21280) refactor(x/auth): audit x/auth changes (#21146) chore: remove todo: "abstract out staking message back to staking" (#21266) ...
Description
Closes: #20971
Hi, @julienrbrt
This should be the simplest implementation method at present, but adding non-modular
autoCli
toautocli.AppOptions
is not very user-friendly. Are there any other good solutions, and are there any plans to improve autocli?Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Documentation