diff --git a/README.MD b/README.MD index 3174772..1901834 100644 --- a/README.MD +++ b/README.MD @@ -13,7 +13,11 @@ A convenient configuration generator based on an `yaml` template with `env` supp GOPATH=./bin go install github.com/evald24/go-gen-config/cmd/go-gen-config ``` -Usage: +## Usage: + +At the beginning, create a file with a configuration template (e.g. [`config.template.yaml`](/example/config.template.yaml)) + +Then execute the generation command: ```zsh ./bin/go-gen-config -t ./example/config.template.yaml -o ./example/config/config.gen.go -c ./example/config.yaml diff --git a/cmd/go-gen-config/main.go b/cmd/go-gen-config/main.go index 441e797..0ef6730 100644 --- a/cmd/go-gen-config/main.go +++ b/cmd/go-gen-config/main.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "log" + "strings" "github.com/evald24/go-gen-config/internal/generator" ) @@ -20,12 +21,10 @@ func main() { flag.StringVar(&configPath, "c", "", "Path to the generate config file (yaml)") flag.Parse() - checkNoEmpty( - map[string]interface{}{ - "template": templatePath, - "ouput": outputPath, - "config": configPath, - }) + checkNoEmpty(map[string]string{ + "template": templatePath, + "ouput": outputPath, + }) gen := generator.New(templatePath, outputPath, configPath) if err := gen.Generate(); err != nil { @@ -33,12 +32,12 @@ func main() { return } - fmt.Println("Generate template done") + fmt.Println("Template generation is complete") } -func checkNoEmpty(paths map[string]interface{}) { - for k := range paths { - if outputPath == "" { +func checkNoEmpty(paths map[string]string) { + for k, v := range paths { + if strings.TrimSpace(v) == "" { log.Fatalf("%v path is empty", k) } }