From 1d71729a7cb3c1267d5f015e5f55193a438c737a Mon Sep 17 00:00:00 2001 From: Mike Lee Date: Fri, 29 Mar 2019 13:35:55 -0400 Subject: [PATCH 1/2] 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() { From e4d1fef8fe8bd256f8c18a65bf8470630eec1d5e Mon Sep 17 00:00:00 2001 From: Mike Lee Date: Fri, 29 Mar 2019 19:24:47 -0400 Subject: [PATCH 2/2] fmt --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index d4c5284..73e8017 100644 --- a/main.go +++ b/main.go @@ -48,7 +48,7 @@ func main() { debug = false all = false singlePackageMode = false - fileMode = false + fileMode = false ) if parameter := g.Request.GetParameter(); parameter != "" { for _, param := range strings.Split(parameter, ",") { @@ -135,7 +135,7 @@ func main() { } if fileMode { - if s := file.GetService(); s != nil && len(s) > 0{ + if s := file.GetService(); s != nil && len(s) > 0 { encoder := NewGenericTemplateBasedEncoder(templateDir, file, debug, destinationDir) for _, tmpl := range encoder.Files() { concatOrAppend(tmpl)