allow to pass additional options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
30
options.go
30
options.go
@@ -1,6 +1,8 @@
|
||||
package flag
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"go.unistack.org/micro/v3/config"
|
||||
)
|
||||
|
||||
@@ -24,3 +26,31 @@ type timeFormatKey struct{}
|
||||
func TimeFormat(s string) config.Option {
|
||||
return config.SetOption(timeFormatKey{}, s)
|
||||
}
|
||||
|
||||
type flagSetKey struct{}
|
||||
|
||||
// FlagSet set flag set name
|
||||
func FlagSet(f *flag.FlagSet) config.Option {
|
||||
return config.SetOption(flagSetKey{}, f)
|
||||
}
|
||||
|
||||
type flagSetNameKey struct{}
|
||||
|
||||
// FlagSetName set flag set name
|
||||
func FlagSetName(n string) config.Option {
|
||||
return config.SetOption(flagSetNameKey{}, n)
|
||||
}
|
||||
|
||||
type flagSetErrorHandlingKey struct{}
|
||||
|
||||
// FlagErrorHandling set flag set error handling
|
||||
func FlagErrorHandling(eh flag.ErrorHandling) config.Option {
|
||||
return config.SetOption(flagSetErrorHandlingKey{}, eh)
|
||||
}
|
||||
|
||||
type flagSetUsageKey struct{}
|
||||
|
||||
// FlagUsage set flag set usage func
|
||||
func FlagUsage(fn func()) config.Option {
|
||||
return config.SetOption(flagSetUsageKey{}, fn)
|
||||
}
|
||||
|
Reference in New Issue
Block a user