2021-06-19 16:00:47 +03:00
|
|
|
package flag
|
|
|
|
|
|
|
|
import (
|
2022-04-01 15:24:56 +03:00
|
|
|
"flag"
|
|
|
|
|
2023-07-30 00:38:15 +03:00
|
|
|
"go.unistack.org/micro/v4/options"
|
2021-06-19 16:00:47 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type sliceDelimKey struct{}
|
|
|
|
|
|
|
|
// SliceDelim set the slice delimeter
|
2023-07-30 00:38:15 +03:00
|
|
|
func SliceDelim(s string) options.Option {
|
|
|
|
return options.ContextOption(sliceDelimKey{}, s)
|
2021-06-19 16:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type mapDelimKey struct{}
|
|
|
|
|
|
|
|
// MapDelim set the map delimeter
|
2023-07-30 00:38:15 +03:00
|
|
|
func MapDelim(s string) options.Option {
|
|
|
|
return options.ContextOption(mapDelimKey{}, s)
|
2021-06-19 16:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type timeFormatKey struct{}
|
|
|
|
|
|
|
|
// TimeFormat set the time format
|
2023-07-30 00:38:15 +03:00
|
|
|
func TimeFormat(s string) options.Option {
|
|
|
|
return options.ContextOption(timeFormatKey{}, s)
|
2021-06-19 16:00:47 +03:00
|
|
|
}
|
2022-04-01 15:24:56 +03:00
|
|
|
|
|
|
|
type flagSetKey struct{}
|
|
|
|
|
|
|
|
// FlagSet set flag set name
|
2023-07-30 00:38:15 +03:00
|
|
|
func FlagSet(f *flag.FlagSet) options.Option {
|
|
|
|
return options.ContextOption(flagSetKey{}, f)
|
2022-04-01 15:24:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type flagSetNameKey struct{}
|
|
|
|
|
|
|
|
// FlagSetName set flag set name
|
2023-07-30 00:38:15 +03:00
|
|
|
func FlagSetName(n string) options.Option {
|
|
|
|
return options.ContextOption(flagSetNameKey{}, n)
|
2022-04-01 15:24:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type flagSetErrorHandlingKey struct{}
|
|
|
|
|
|
|
|
// FlagErrorHandling set flag set error handling
|
2023-07-30 00:38:15 +03:00
|
|
|
func FlagErrorHandling(eh flag.ErrorHandling) options.Option {
|
|
|
|
return options.ContextOption(flagSetErrorHandlingKey{}, eh)
|
2022-04-01 15:24:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type flagSetUsageKey struct{}
|
|
|
|
|
|
|
|
// FlagUsage set flag set usage func
|
2023-07-30 00:38:15 +03:00
|
|
|
func FlagUsage(fn func()) options.Option {
|
|
|
|
return options.ContextOption(flagSetUsageKey{}, fn)
|
2022-04-01 15:24:56 +03:00
|
|
|
}
|
2022-04-02 15:12:34 +03:00
|
|
|
|
|
|
|
type flagEnvKey struct{}
|
|
|
|
|
|
|
|
// FlagEnv set flag set usage func
|
2023-07-30 00:38:15 +03:00
|
|
|
func FlagEnv(n string) options.Option {
|
|
|
|
return options.ContextOption(flagEnvKey{}, n)
|
2022-04-02 15:12:34 +03:00
|
|
|
}
|