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

fix: rebind projKey flag to update subcommand #62

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

k3llymariee
Copy link
Contributor

@k3llymariee k3llymariee commented Mar 25, 2024

running into issues with duplicate flag names in different commands - rebinding the flag in the subcommand might not be the "right way" to do this but it works for now!

related issue: spf13/viper#233

@@ -67,6 +67,9 @@ func runUpdate(cmd *cobra.Command, args []string) error {
viper.GetString("baseUri"),
)

// rebind flag to this subcommand
viper.BindPFlag("projKey", cmd.Flags().Lookup("projKey"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we basically rebinding it before we pass the data in?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess somewhere in the issue you linked I saw that since these are "local flags" for a subcommand they get overwritten

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a helper function that rebinds all the flags were going to use/re-use or something since we're going to have a lot of subcommands.

@@ -67,6 +67,9 @@ func runUpdate(cmd *cobra.Command, args []string) error {
viper.GetString("baseUri"),
)

// rebind flag to this subcommand
viper.BindPFlag("projKey", cmd.Flags().Lookup("projKey"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a helper function that rebinds all the flags were going to use/re-use or something since we're going to have a lot of subcommands.

Copy link
Contributor

@dbolson dbolson left a comment

Choose a reason for hiding this comment

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

We should do this for the create command too since it's probably only showing up for update because we call create first.

@k3llymariee k3llymariee merged commit 1f0f898 into main Mar 25, 2024
2 checks passed
@k3llymariee k3llymariee deleted the kelly/rebind-projkey-flag branch March 25, 2024 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants