-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.go
40 lines (34 loc) · 802 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"flag"
"fmt"
"os"
"github.com/losisin/helm-values-schema-json/pkg"
)
func main() {
// Load configuration from a YAML file
fileConfig, err := pkg.LoadConfig(".schema.yaml")
if err != nil {
fmt.Println("Error loading config file:", err)
}
// Parse CLI flags
flagConfig, output, err := pkg.ParseFlags(os.Args[0], os.Args[1:])
if err == flag.ErrHelp {
fmt.Println(output)
return
} else if err != nil {
fmt.Println("Error parsing flags:", output)
return
}
// Merge configurations, giving precedence to CLI flags
var finalConfig *pkg.Config
if fileConfig != nil {
finalConfig = pkg.MergeConfig(fileConfig, flagConfig)
} else {
finalConfig = flagConfig
}
err = pkg.GenerateJsonSchema(finalConfig)
if err != nil {
fmt.Println("Error:", err)
}
}