-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Command passed to SetHelpFunc doesn't have a context #2240
Comments
Will see if I can raise a PR to fix this. |
Frassle
added a commit
to Frassle/cobra
that referenced
this issue
Feb 20, 2025
Frassle
added a commit
to Frassle/cobra
that referenced
this issue
Feb 20, 2025
github-merge-queue bot
pushed a commit
to pulumi/pulumi
that referenced
this issue
Feb 20, 2025
Fixes #18659 Comment in code pretty much covers it, but repeating here: You'd think you could use cmd.Context() in the help function but cobra doesn't set context on the cmd even though the parent help command has it. I've raised spf13/cobra#2240 to see about fixing it.
Frassle
added a commit
to Frassle/cobra
that referenced
this issue
Feb 20, 2025
Frassle
added a commit
to Frassle/cobra
that referenced
this issue
Feb 20, 2025
marckhouzam
pushed a commit
that referenced
this issue
Feb 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using
SetHelpFunc
the function gets given aCommand
object and you'd think you could useContext()
to get the right context off the command, but it doesn't actually get set.We hit this in pulumi: pulumi/pulumi#18659
I can work around via just a context.Background call instead, but feels like this should just work as the parent "help" command does have a context.
The text was updated successfully, but these errors were encountered: