Skip to content
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

R4R: Standardize CLI Exports from Modules #2840

Merged
merged 13 commits into from
Nov 19, 2018

Conversation

jackzampolin
Copy link
Member

@jackzampolin jackzampolin commented Nov 15, 2018

Addresses #2729

This PR refactors the CLI code to clean it up and provide modules with a standard interface for exposing client functionality. When reviewing, start with the interface in types/moduleClients.go. Each module that exposes functionality under either the gaiacli query or gaiacli tx sub-commands has a new file x/{{ .Module.Name }}/client/moduleClient.go that implements the interface and stitches together functionality from /x/{{ .Module.Name }}/client/cli (and once #2836 is merged another PR will include /x/{{ .Module.Name }}/client/rest routes).

  • Added entries in PENDING.md with issue #
  • rereviewed Files changed in the github PR explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Nov 15, 2018

Codecov Report

Merging #2840 into develop will decrease coverage by 0.01%.
The diff coverage is 0.52%.

@@             Coverage Diff             @@
##           develop    #2840      +/-   ##
===========================================
- Coverage       57%   56.99%   -0.02%     
===========================================
  Files          131      120      -11     
  Lines         8581     8308     -273     
===========================================
- Hits          4892     4735     -157     
+ Misses        3359     3257     -102     
+ Partials       330      316      -14

@jackzampolin jackzampolin changed the title WIP: Standardize CLI Interactions R4R: Standardize CLI Interactions Nov 16, 2018
@jackzampolin jackzampolin changed the title R4R: Standardize CLI Interactions R4R: Standardize CLI Exports from Modules Nov 16, 2018
types/moduleClients.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go for me

@alessio
Copy link
Contributor

alessio commented Nov 19, 2018

Tests are failing @jackzampolin

@cwgoes
Copy link
Contributor

cwgoes commented Nov 19, 2018

The test failures are unrelated to this PR's changes - #2781 (comment).

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substance LGTM, a few cleanup changes req'd.

// TODO: Make the lcd command take a list of ModuleClient
mc := []sdk.ModuleClients{
govClient.NewModuleClient(storeGov, cdc),
distClient.NewModuleClient("", cdc),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why empty string? Do we never query the distribution store?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is currently no query functionality in the dist module. Rigel is working on that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do already know the name of the store key though

@@ -80,7 +80,7 @@ func main() {
stakecmd.GetCmdQueryRedelegation("stake", cdc),
stakecmd.GetCmdQueryRedelegations("stake", cdc),
slashingcmd.GetCmdQuerySigningInfo("slashing", cdc),
authcmd.GetAccountCmd("acc", cdc, types.GetAccountDecoder(cdc)),
authcmd.GetAccountCmd("acc", cdc),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "acc" be a constant somewhere (storeAcc maybe)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know really. This is how I found the code. I've opened this issue to track. I'll update to make it a const.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -71,7 +70,7 @@ func main() {
// start with commands common to basecoin
rootCmd.AddCommand(
client.GetCommands(
authcmd.GetAccountCmd("acc", cdc, types.GetAccountDecoder(cdc)),
authcmd.GetAccountCmd("acc", cdc),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto (should be a constant)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

docs/examples/democoin/x/pow/client/cli/tx.go Show resolved Hide resolved
x/auth/client/cli/account.go Show resolved Hide resolved
x/auth/client/cli/sign.go Show resolved Hide resolved

// GetQueryCmd returns the cli query commands for this module
func (mc ModuleClient) GetQueryCmd() *cobra.Command {
return &cobra.Command{Hidden: true}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in, no query command? maybe we can return nil or return a boolean to indicate whether the module has any query commands.

Copy link
Member Author

@jackzampolin jackzampolin Nov 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this also works just as well. Would you like me to change it?

Copy link
Contributor

@cwgoes cwgoes Nov 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what Hidden: true does (I guess that it returns a nil-ish command that doesn't show up?) - I do think returning nil would be cleaner

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this in per discussion with @cwgoes

x/stake/client/cli/query.go Show resolved Hide resolved
@jackzampolin jackzampolin merged commit f525717 into develop Nov 19, 2018
@jackzampolin jackzampolin deleted the jack/standardize-cli-interactions branch November 19, 2018 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants