-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: main
Are you sure you want to change the base?
Conversation
|
||
type commandKey struct{} | ||
|
||
func WithCommand(ctx context.Context, cmd *cobra.Command) context.Context { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)
?
9314b92
to
81995d3
Compare
81995d3
to
5a47482
Compare
const ( | ||
NameArgumentName = "name" | ||
NamesArgumentName = "name(s)" | ||
) |
There was a problem hiding this comment.
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.
var ( | ||
FaintColor = color.New(color.Faint) | ||
InfoColor = color.New(color.FgCyan) | ||
SuccessColor = color.New(color.FgGreen) | ||
WarnColor = color.New(color.FgYellow) | ||
ErrorColor = color.New(color.FgRed) | ||
BoldColor = color.New(color.Bold) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that we already have compnent/colorable-tty.go
which holds similar color specific helpers. Check to see how we can combine both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestion on the package name characters
?
What this PR does / why we need it
Add additional generic components and helpers functions
Arg
,Error
andExtend
helpers undercommand
packagecomponent/characters
packagecomponent/printer
packagecomponent/tabwriter
packageWhich issue(s) this PR fixes
Fixes #
Describe testing done for PR
Release note
Additional information
Special notes for your reviewer