7
7
8
8
"github.com/alecthomas/errors"
9
9
"github.com/alecthomas/kong"
10
+ "golang.org/x/text/cases"
11
+ "golang.org/x/text/language"
10
12
)
11
13
12
14
func CreateLoader (r io.Reader ) (kong.Resolver , error ) {
@@ -28,12 +30,13 @@ func CreateLoader(r io.Reader) (kong.Resolver, error) {
28
30
}
29
31
30
32
func flatten (config map [string ]interface {}) map [string ]interface {} {
33
+ caser := cases .Title (language .English )
31
34
flat := map [string ]interface {}{}
32
35
for k , v := range config {
33
36
switch v := v .(type ) {
34
37
case map [string ]interface {}:
35
38
for k2 , v2 := range flatten (v ) {
36
- flat [camelCase (k )+ strings . Title (camelCase (k2 ))] = v2
39
+ flat [camelCase (k )+ caser . String (camelCase (k2 ))] = v2
37
40
}
38
41
default :
39
42
flat [k ] = v
@@ -43,6 +46,7 @@ func flatten(config map[string]interface{}) map[string]interface{} {
43
46
}
44
47
45
48
func camelCase (s string ) string {
46
- out := strings .ReplaceAll (strings .Title (strings .ReplaceAll (s , "-" , " " )), " " , "" )
49
+ caser := cases .Title (language .English )
50
+ out := strings .ReplaceAll (caser .String (strings .ReplaceAll (s , "-" , " " )), " " , "" )
47
51
return strings .ToLower (out [:1 ]) + out [1 :]
48
52
}
0 commit comments