micro-config-flag/options.go
Vasiliy Tolstov 4b7541ebaa allow to pass additional options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-01 15:24:56 +03:00

57 lines
1.2 KiB
Go

package flag
import (
"flag"
"go.unistack.org/micro/v3/config"
)
type sliceDelimKey struct{}
// SliceDelim set the slice delimeter
func SliceDelim(s string) config.Option {
return config.SetOption(sliceDelimKey{}, s)
}
type mapDelimKey struct{}
// MapDelim set the map delimeter
func MapDelim(s string) config.Option {
return config.SetOption(mapDelimKey{}, s)
}
type timeFormatKey struct{}
// TimeFormat set the time format
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)
}