You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are you running the latest v3 release? The list of releases is here.
Did you check the manual for your release? The v3 manual is here.
Did you perform a search about this feature? Here's the GitHub guide about searching.
What problem does this solve?
The standard library's flag package has had flag.TextVar since 1.19 which allows any type that satisfies encoding.TextMarshaller and encoding.TextUnmarshaller to be set using flags. A good use for this is to set log level using strings such as slog.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 and TextFlag.
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.
* 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]>
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: