Skip to content

Commit

Permalink
add parameter file-mode for template at file level (#143)
Browse files Browse the repository at this point in the history
add parameter file-mode for template at file level
  • Loading branch information
moul authored May 30, 2019
2 parents 5b5d8bf + e4d1fef commit 3a6b47d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ",") {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 3a6b47d

Please sign in to comment.