From 1d71729a7cb3c1267d5f015e5f55193a438c737a Mon Sep 17 00:00:00 2001 From: Mike Lee Date: Fri, 29 Mar 2019 13:35:55 -0400 Subject: [PATCH] add parameter file-mode for templates that wish to parse at a file level instead of each service --- main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.go b/main.go index dea8384..d4c5284 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,7 @@ func main() { debug = false all = false singlePackageMode = false + fileMode = false ) if parameter := g.Request.GetParameter(); parameter != "" { for _, param := range strings.Split(parameter, ",") { @@ -85,6 +86,14 @@ func main() { default: log.Printf("Err: invalid value for debug: %q", parts[1]) } + case "file-mode": + switch strings.ToLower(parts[1]) { + case boolTrue, "t": + fileMode = true + case boolFalse, "f": + default: + log.Printf("Err: invalid value for file-mode: %q", parts[1]) + } default: log.Printf("Err: unknown parameter: %q", param) } @@ -125,6 +134,17 @@ func main() { continue } + if fileMode { + if s := file.GetService(); s != nil && len(s) > 0{ + encoder := NewGenericTemplateBasedEncoder(templateDir, file, debug, destinationDir) + for _, tmpl := range encoder.Files() { + concatOrAppend(tmpl) + } + } + + continue + } + for _, service := range file.GetService() { encoder := NewGenericServiceTemplateBasedEncoder(templateDir, service, file, debug, destinationDir) for _, tmpl := range encoder.Files() {