-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Text flags #2051
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
Labels
area/v3
relates to / is being considered for v3
status/triage
maintainers still need to look into this
Comments
@somebadcode Yes please !!!! |
somebadcode
added a commit
to somebadcode/urfave-cli
that referenced
this issue
Feb 10, 2025
* Added `TextFlag` which supports setting values for types that satisfies the `encoding.TextMarshaller` and `encoding.TextUnmarshaller` which is very handy when you want to set log levels or string-like types that satifies the interfaces. Fixes: urfave#2051 Signed-off-by: Tobias Dahlberg <[email protected]>
somebadcode
added a commit
to somebadcode/urfave-cli
that referenced
this issue
Apr 18, 2025
* Added `TextFlag` which supports setting values for types that satisfies the `encoding.TextMarshaller` and `encoding.TextUnmarshaller` which is very handy when you want to set log levels or string-like types that satifies the interfaces. Fixes: urfave#2051 Signed-off-by: Tobias Dahlberg <[email protected]>
@somebadcode This is what I have and it works
Only difference is that it uses the GenericFlag instead of a new TextFlag. While I like the TextFlag approach I think the current plumbing of cli allows you to achieve what you want without a new flag in the mix.
|
somebadcode
added a commit
to somebadcode/urfave-cli
that referenced
this issue
Apr 19, 2025
* Added `TextFlag` which supports setting values for types that satisfies the `encoding.TextMarshaller` and `encoding.TextUnmarshaller` which is very handy when you want to set log levels or string-like types that satifies the interfaces. Fixes: urfave#2051 Signed-off-by: Tobias Dahlberg <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/v3
relates to / is being considered for v3
status/triage
maintainers still need to look into this
Checklist
What problem does this solve?
The standard library's
flag
package has hadflag.TextVar
since 1.19 which allows any type that satisfiesencoding.TextMarshaller
andencoding.TextUnmarshaller
to be set using flags. A good use for this is to set log level using strings such asslog.LevelVar
.Other logging packages such as
go.uber.org/zap
satisfies these interfaces for its atomic level type. You can have a logger before the log level has been set. It'll be ready before arguments have been parsed and output structured logs in case of a parse error.Solution description
Implement
TextValue
andTextFlag
.Describe alternatives you've considered
Here's what I had to implement to get the functionality. It would be nice to see this being supported by this package.
I can contribute a solution based on this if so desired.
The text was updated successfully, but these errors were encountered: