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 additional generic components and helpers #224

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anujc25
Copy link
Contributor

@anujc25 anujc25 commented Jan 21, 2025

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

Release note


Additional information

Special notes for your reviewer


type commandKey struct{}

func WithCommand(ctx context.Context, cmd *cobra.Command) context.Context {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we rename this to WithContext? So, invocation will be command.WithContext(ctx, cmd) ?

return context.WithValue(ctx, commandKey{}, cmd)
}

func CommandFromContext(ctx context.Context) *cobra.Command {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we rename this to FromContext? So, invocation will be command.FromContext(ctx) ?

@anujc25 anujc25 marked this pull request as ready for review January 23, 2025 17:55
@anujc25 anujc25 requested a review from a team as a code owner January 23, 2025 17:55
Comment on lines +12 to +15
const (
NameArgumentName = "name"
NamesArgumentName = "name(s)"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are these generic enough to be kept here? Also applies to NameArg, OptionalNameArg, NamesArg functions below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants