-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: add basic autocli config to every module #13786
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #13786 +/- ##
==========================================
- Coverage 56.78% 56.70% -0.08%
==========================================
Files 644 637 -7
Lines 54952 54585 -367
==========================================
- Hits 31203 30951 -252
+ Misses 21210 21130 -80
+ Partials 2539 2504 -35
|
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.
left one comment, it looks good
x/authz/autocli.go
Outdated
var AutoCLIOptions = &autocliv1.ModuleOptions{ | ||
Query: &autocliv1.ServiceCommandDescriptor{Service: _Query_serviceDesc.ServiceName}, | ||
Tx: &autocliv1.ServiceCommandDescriptor{Service: _Msg_serviceDesc.ServiceName}, | ||
} |
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.
could we add a quick few sentences on what each of these do in a doc. We can expand on it later.
How should we describe that in the docs? Do you think it worth to add a page in https://docs.cosmos.network/main/building-modules/{...} specifically for AutoCLI? |
hello @aaronc. Me and @faddat are currently trying to implement autocli for Osmosis here. We implemented autocli on |
it doesn't seem like you have wired this up in the app.go, we will work on docs so it might help to wait for those. |
@rusakh we don't have a full to end setup ready for this yet. I will be working on showing integration with the actual CLI in a follow-up PR. Also only queries are supported thus far. A bunch of pieces still need to be built |
One thing I'm considering is if we can auto-discover the config for modules with only one query and msg service. Maybe that should be the default rather than needing it to be explicit like I did in this PR. You should only need to add the config manually if there's customization needed and/or multiple services. |
thank you for your response @aaronc! I will look into next pr then. |
I made substantial changes so it would be good to get it re-approved
I changed it so that it auto-discovers options where it can. The PR is now substantially different and smaller. |
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.
lgtm! few nits
@@ -35,4 +62,25 @@ func (a AutoCLIQueryService) AppOptions(context.Context, *autocliv1.AppOptionsRe | |||
}, nil | |||
} | |||
|
|||
type autocliConfigurator struct { |
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.
Nit move that down next to its methods.
Can you explain the use case?
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.
This is just so that we can call RegisterServices
to discover the module's service names.
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.
updated
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.
I guess this PR using the configurator approach is an intermediary solution, right? I'm in favor of removing the Configurator
interface ultimately (since we're going the interfaces approach)
AppModule's RegisterServices should be simply RegisterServices(grpc.ServiceRegistrar)
, which would remove autocliConfigurator
from this file.
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.
Exactly
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Could I get one more review here @tac0turtle or @AmauryM ? |
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.
lgtm
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.
LGTM
Service: govv1.Msg_ServiceDesc.ServiceName, | ||
// map v1beta1 as a sub-command | ||
SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{ | ||
"v1beta1": {Service: govv1beta1.Msg_ServiceDesc.ServiceName}, |
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.
autocli is not wired up to simd's root cmd, right? When I try simd q gov
there's no v1beta1 subcommand. I guess there's only the remote info part of autocli for now
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.
Exactly
@@ -22,6 +24,31 @@ func NewAutoCLIQueryService(appModules map[string]module.AppModule) *AutoCLIQuer | |||
AutoCLIOptions() *autocliv1.ModuleOptions | |||
}); ok { | |||
moduleOptions[modName] = autoCliMod.AutoCLIOptions() | |||
} else { | |||
// try to auto-discover options based on the last msg and query |
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.
I was asking above because what happens when we wire up autocli with the root cobra command, and there are conflicts in command names between this auto-discovered one and custom ones?
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.
AutoCLI prefers the custom commands
@@ -35,4 +62,25 @@ func (a AutoCLIQueryService) AppOptions(context.Context, *autocliv1.AppOptionsRe | |||
}, nil | |||
} | |||
|
|||
type autocliConfigurator struct { |
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.
I guess this PR using the configurator approach is an intermediary solution, right? I'm in favor of removing the Configurator
interface ultimately (since we're going the interfaces approach)
AppModule's RegisterServices should be simply RegisterServices(grpc.ServiceRegistrar)
, which would remove autocliConfigurator
from this file.
Description
Closes: #13293
This just adds the most basic necessary configuration to each module (essentially the name of the query and msg services). We can deal with more customization and help text in follow-ups.
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...
!
to 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.
I have...
!
in the type prefix if API or client breaking change