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

Add minimal Context support to cobra #727

Closed
wants to merge 1 commit into from
Closed

Add minimal Context support to cobra #727

wants to merge 1 commit into from

Conversation

flimzy
Copy link
Contributor

@flimzy flimzy commented Aug 12, 2018

RFC. This PR is meant to demonstrate a possible, minimal solution to #563.

I welcome feedback, suggestions, and alternatives.

@aidansteele
Copy link

I think this would make a great addition to cobra. When I was playing with the functionality introduced in your PR, something caught me: I had assumed -- perhaps naïvely -- that a parent command's context would "trickle down" into subcommands. I tried accessing a value stored in the root command's context by accessing child.Context() and it wasn't there.

What semantics do you think make the most sense? I'm happy to hear that my initial assumptions were silly, but I thought it'd be worth a discussion.

@flimzy
Copy link
Contributor Author

flimzy commented Dec 17, 2018

@aidansteele How are you trying to set context in the root command, then access in the child command? Can you show some sample code? I'm not quite visualizing what you're doing, so it's hard to comment.

@github-actions
Copy link

github-actions bot commented Apr 9, 2020

This PR is being marked as stale due to a long period of inactivity

@marckhouzam
Copy link
Collaborator

PR #893 which has been merged has brought context support to Cobra.

This PR can therefore be closed /cc @jpmcb

@johnSchnake
Copy link
Collaborator

Per comment; closing.

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.

None yet

4 participants