add parameter file-mode for template at file level (#143)

add parameter file-mode for template at file level
This commit is contained in:
Manfred Touron 2019-05-30 20:12:52 +02:00 committed by GitHub
commit 3a6b47dc92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

20
main.go
View File

@ -48,6 +48,7 @@ func main() {
debug = false debug = false
all = false all = false
singlePackageMode = false singlePackageMode = false
fileMode = false
) )
if parameter := g.Request.GetParameter(); parameter != "" { if parameter := g.Request.GetParameter(); parameter != "" {
for _, param := range strings.Split(parameter, ",") { for _, param := range strings.Split(parameter, ",") {
@ -85,6 +86,14 @@ func main() {
default: default:
log.Printf("Err: invalid value for debug: %q", parts[1]) 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: default:
log.Printf("Err: unknown parameter: %q", param) log.Printf("Err: unknown parameter: %q", param)
} }
@ -125,6 +134,17 @@ func main() {
continue 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() { for _, service := range file.GetService() {
encoder := NewGenericServiceTemplateBasedEncoder(templateDir, service, file, debug, destinationDir) encoder := NewGenericServiceTemplateBasedEncoder(templateDir, service, file, debug, destinationDir)
for _, tmpl := range encoder.Files() { for _, tmpl := range encoder.Files() {