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

refactor(keys): remove duplicate --home flag #17197

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

zakir-code
Copy link
Contributor

Description

Closes: #XXXX


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@zakir-code zakir-code requested a review from a team as a code owner July 30, 2023 10:32
@github-actions github-actions bot added C:CLI C:Keys Keybase, KMS and HSMs labels Jul 30, 2023
@julienrbrt
Copy link
Member

Could you explain the rationale of this change? Previous behavior, new behavior etc.. ?

@zakir-code
Copy link
Contributor Author

zakir-code commented Jul 30, 2023

rootcmd already has --home flag set, this PR has no side effects, other subcommands with --home flag can also be removed

executor := cmtcli.PrepareBaseCmd(rootCmd, envPrefix, defaultHome)

// PrepareBaseCmd is meant for CometBFT and other servers
func PrepareBaseCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor {
	cobra.OnInitialize(func() { initEnv(envPrefix) })
	cmd.PersistentFlags().StringP(HomeFlag, "", defaultHome, "directory for config and data")
	cmd.PersistentFlags().Bool(TraceFlag, false, "print out full stack trace on errors")
	cmd.PersistentPreRunE = concatCobraCmdFuncs(bindFlagsLoadViper, cmd.PersistentPreRunE)
	return Executor{cmd, os.Exit}
}

@julienrbrt julienrbrt self-assigned this Jul 30, 2023
@julienrbrt
Copy link
Member

julienrbrt commented Jul 31, 2023

Thanks for the PR, but imho we possibly should not do this: We want to remove our reliance on CometBFT API (PrepareBaseCmd is a good example of things we should be removing) and we want as well our commands to be usable standalone if needed.

Now, you need to know that the home flag should be added if you do not want to always specify the keyring directory directly or call ReadPersistentCommandFlags.

EDIT 1: Sorry, didn't mean to close.
EDIT 2: For the keys command it looks like you need quite much prior knowledge to get it working standalone, so I guess this is fine. For the other commands using --home I believe we shouldn't remove it as they are easily usable standalone.

@julienrbrt julienrbrt closed this Jul 31, 2023
@julienrbrt julienrbrt reopened this Jul 31, 2023
@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Jul 31, 2023
@julienrbrt julienrbrt added this pull request to the merge queue Jul 31, 2023
Merged via the queue into cosmos:main with commit edba186 Jul 31, 2023
mergify bot pushed a commit that referenced this pull request Jul 31, 2023
@zakir-code
Copy link
Contributor Author

I agree with you, but I think it should be unified with other subcommands.

Below is my commit with all "--home" flag removed, Because I don't know your thoughts, I didn't create a PR

zakir-code@66c3ffc

@julienrbrt
Copy link
Member

julienrbrt commented Jul 31, 2023

I am all for consistency, however ease of use should prevail.
Feel free to open that PR, there are some good things in it.

julienrbrt added a commit that referenced this pull request Jul 31, 2023
)

Co-authored-by: zakir <80246097+zakir-code@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@faddat faddat mentioned this pull request Nov 8, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:CLI C:Keys Keybase, KMS and HSMs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants