-
Notifications
You must be signed in to change notification settings - Fork 607
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
osmocli: parse Use
field's arguments dynamically from a message
#6005
Conversation
devbot add changelog misc osmocli: parse Use field's arguments dynamically |
ed949f2
to
9bd8cdf
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.
Hey @pysel love this change, I think this is a great idea!
I was manually testing out things, and I noticed that arguments have trouble getting dynamically parsed methods using custom parser or custom logic. Here's an example
(base) matt@MacBook-Pro build % ./osmosisd q gamm estimate-swap-exact-amount-in --help
Query estimate-swap-exact-amount-in.
Example:
$ osmosisd q gamm estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3
Usage:
osmosisd query gamm estimate-swap-exact-amount-in [flags]
notice how it failed to dynamically place the usage.
After we get this fixed I think we should be good to go :) Nice work!
hey @mattverse! weird, I just tried it on the same command, seems to be working fine:
could you please confirm you used an updated binary? thanks! |
@pysel What is the binary version you see? The current one I have is
|
@mattverse have you installed the binary via |
@pysel I use |
hey @mattverse, I fixed the problem (it was outdated osmoutils version in go.mod), it should be good now. |
btw, this osmoutils version problem took some time to be figured out. I think we might like to revisit PR that was closed recently, which idea was to update versions of workspace's submodules in go.mod when anything in them changes. if we had this functionality, the mentioned problem wouldn't have occurred, wdyt? EDIT: another option is to maybe add this functionality to devbot. cc: @ValarDragon |
I'm down to re-reviewing #4667, sorry for the delay on the review for that one |
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, nice work 🌮
) * dynamically attach fields' values to use of cobra cmd * update changelog * add comment * support both tx/q * fix use overwriting + owner to non-attachable fields * change QueryDescriptor * go fmt * remove params in SimpleQueryCmd * refactor TxCliDesc to not pass hardcoded args * field names to kebab * add test for descs * reset statik * Update x/concentrated-liquidity/tick_test.go * Update x/concentrated-liquidity/client/grpc/grpc_query.go * Update x/concentrated-liquidity/client/grpc/grpc_query.go * reset grpc * reset grpc dt-det * reset all grpcs * remove testing function * self review * update osmoutils version --------- Co-authored-by: devbot-wizard <[email protected]> (cherry picked from commit c9cbb9c) # Conflicts: # CHANGELOG.md # go.mod # go.sum
) * dynamically attach fields' values to use of cobra cmd * update changelog * add comment * support both tx/q * fix use overwriting + owner to non-attachable fields * change QueryDescriptor * go fmt * remove params in SimpleQueryCmd * refactor TxCliDesc to not pass hardcoded args * field names to kebab * add test for descs * reset statik * Update x/concentrated-liquidity/tick_test.go * Update x/concentrated-liquidity/client/grpc/grpc_query.go * Update x/concentrated-liquidity/client/grpc/grpc_query.go * reset grpc * reset grpc dt-det * reset all grpcs * remove testing function * self review * update osmoutils version --------- Co-authored-by: devbot-wizard <[email protected]> (cherry picked from commit c9cbb9c) # Conflicts: # CHANGELOG.md # go.mod # go.sum
…port #6005) (#6241) Co-authored-by: Roman <[email protected]>
…ckport #6005) (#6240) * osmocli: parse Use field's arguments dynamically from a message (backport #6005) * go sum --------- Co-authored-by: Roman <[email protected]>
) * dynamically attach fields' values to use of cobra cmd * update changelog * add comment * support both tx/q * fix use overwriting + owner to non-attachable fields * change QueryDescriptor * go fmt * remove params in SimpleQueryCmd * refactor TxCliDesc to not pass hardcoded args * field names to kebab * add test for descs * reset statik * Update x/concentrated-liquidity/tick_test.go * Update x/concentrated-liquidity/client/grpc/grpc_query.go * Update x/concentrated-liquidity/client/grpc/grpc_query.go * reset grpc * reset grpc dt-det * reset all grpcs * remove testing function * self review * update osmoutils version --------- Co-authored-by: devbot-wizard <[email protected]>
Closes: #XXX
What is the purpose of the change
In current
osmocli
implementation, in order to create a cli command you need to create a descriptor of this command (example here). The problem with this approach is that it is easy to forget to pass some arguments intoUse
field of descriptor, which leads to inconsistentUsage
s of cli commands (example PR which fixes mistakenly dropped arguments).In this PR I propose to attach arguments dynamically during command construction. It will help avoid the mentioned inconsistencies. If this gets merged, there will be no need to provide message's and query's arguments to descriptors. Ex:
To reviewers: right now I only implemented it for queries. If folks like the idea of this PR, I will continue to do the same for txs and migrate the repo to the new usage of osmocliTesting and Verifying
Manual + added test