Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
evald24 committed Mar 31, 2022
1 parent f60296d commit f2a9b44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions cmd/go-gen-config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"log"
"strings"

"github.com/evald24/go-gen-config/internal/generator"
)
Expand All @@ -20,25 +21,23 @@ 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 {
fmt.Println(err)
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)
}
}
Expand Down

0 comments on commit f2a9b44

Please sign in to comment.