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: Ensure all CLI queries respect output flags #3320

Merged
merged 8 commits into from
Jan 22, 2019

Conversation

jackzampolin
Copy link
Member

@jackzampolin jackzampolin commented Jan 18, 2019

Closes #3268
Fixes #3255
Closes #2607

There were also some small changes to 3 staking commands to remove excessive flags and replace them with arguments. Each of these commands were the singular version (redelegation vs redelegations) where the plural took no flags, and the singular took 2-3. This PR results in a much cleaner and consistent UX for queries on the command line.

I've also added some comments here to help reviewers.

  • Wrote tests
  • Updated relevant documentation (docs/)
  • 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 Jan 18, 2019

Codecov Report

Merging #3320 into develop will decrease coverage by 0.71%.
The diff coverage is 3.59%.

@@             Coverage Diff             @@
##           develop    #3320      +/-   ##
===========================================
- Coverage    55.64%   54.92%   -0.72%     
===========================================
  Files          132      132              
  Lines         9559     9680     +121     
===========================================
- Hits          5319     5317       -2     
- Misses        3903     4026     +123     
  Partials       337      337

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

some minor comments

PENDING.md Outdated Show resolved Hide resolved
docs/gaia/gaiacli.md Show resolved Hide resolved
client/context/context.go Show resolved Hide resolved
x/gov/client/utils/query.go Outdated Show resolved Hide resolved
x/staking/types/validator.go Show resolved Hide resolved
@jackzampolin jackzampolin mentioned this pull request Jan 18, 2019
7 tasks
@jackzampolin jackzampolin added C:CLI ready-for-review T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). labels Jan 18, 2019
x/gov/client/utils/query.go Show resolved Hide resolved
x/auth/account.go Show resolved Hide resolved
x/auth/account.go Show resolved Hide resolved
x/auth/account.go Show resolved Hide resolved
x/staking/types/delegation.go Show resolved Hide resolved
x/staking/types/validator_test.go Outdated Show resolved Hide resolved
x/staking/types/validator_test.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.

Comments addressed, thus nihil obstat from me.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Looks great @jackzampolin! I left some initial feedback, but have not manually tested yet. I will be doing that shortly.

cmd/gaia/cli_test/test_helpers.go Outdated Show resolved Hide resolved
x/auth/account.go Show resolved Hide resolved
x/distribution/client/cli/query.go Show resolved Hide resolved

func (vs ValidatorSlashEvents) String() string {
out := "Validator Slash Events:\n"
for i, sl := range vs {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these have newlines appended?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are actually multiline strings and the newlines are added properly. Are you seeing issues when using that function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Im just thinking how will multiple slashes be separated?

x/gov/client/utils/query.go Outdated Show resolved Hide resolved
x/gov/depositsvotes.go Outdated Show resolved Hide resolved
x/gov/depositsvotes.go Outdated Show resolved Hide resolved
x/gov/depositsvotes.go Outdated Show resolved Hide resolved
x/staking/types/delegation.go Outdated Show resolved Hide resolved
x/staking/types/delegation.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

I also noticed some decimal values are stringified and others are not (e.g. gov vs distr)

cmd := fmt.Sprintf("gaiacli query gov proposals %v", f.Flags())
stdout, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
if strings.Contains(stderr, "No matching proposals found") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @jackzampolin -- we should use error variables in the future (e.g. strings.Contains(stderr, gov.ErrNoMatchingProposals)

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely. There is a bunch more that needs to be done to standardize errors across the various client software.

}

func (p Proposer) String() string {
return fmt.Sprintf("Proposal w/ ID %d was proposed by %s", p.ProposalID, p.Proposer)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Sprintf("Proposal w/ ID %d was proposed by %s", p.ProposalID, p.Proposer)
return fmt.Sprintf("Proposal with ID %d was proposed by %s", p.ProposalID, p.Proposer)


// QueryProposalByID takes a proposalID and returns a proposal
func QueryProposalByID(proposalID uint64, cliCtx context.CLIContext, cdc *codec.Codec, queryRoute string) ([]byte, error) {
// Construct query
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Construct query

@jackzampolin jackzampolin merged commit 9f50c9f into develop Jan 22, 2019
@@ -37,10 +33,18 @@ BREAKING CHANGES
* [\#3064](https://github.com/cosmos/cosmos-sdk/issues/3064) Sanitize `sdk.Coin` denom. Coins denoms are now case insensitive, i.e. 100fooToken equals to 100FOOTOKEN.
* [\#3195](https://github.com/cosmos/cosmos-sdk/issues/3195) Allows custom configuration for syncable strategy
* [\#3242](https://github.com/cosmos/cosmos-sdk/issues/3242) Fix infinite gas
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

@jackzampolin this doesn't look intentional - merge artifact?

Copy link
Member Author

Choose a reason for hiding this comment

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

can we take care of this in the release PR? 😬 sorry about this

@rigelrozanski rigelrozanski deleted the jack/cli-outputs branch February 20, 2019 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants