Skip to content

Commit

Permalink
Added warning about non-list parameters to placeholders with join del…
Browse files Browse the repository at this point in the history
…imiters.
  • Loading branch information
Knetic committed Sep 19, 2015
1 parent 6107cd9 commit 8cde9c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TemplatedProject.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type TemplatedProject struct {
rootDirectory string

missingParameters StringSet
incorrectParameters StringSet
}

/*
Expand Down Expand Up @@ -262,6 +263,10 @@ func (this *TemplatedProject) replaceStringParameters(input string, parameters m
this.missingParameters.Add(parameterName)
} else {

if(len(parameterValues) == 1) {
this.incorrectParameters.Add(parameterName)
}

sequence = strings.Join(parameterValues, separator)
resultBuffer.WriteString(sequence)
}
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ func createProject(settings RunSettings, registry *TemplateRegistry) {
fmt.Println(value)
}
}

if project.incorrectParameters.Length() > 0 {

fmt.Println("Project generated, but some placeholders in the template were specified with a join character ('[]'), but the given parameter was not a list")
fmt.Println("This may mean you need to specify the following parameters as a comma-separated list")

for _, value := range project.incorrectParameters.GetSlice() {
fmt.Println(value)
}
}
}

func exitWith(message string, err error, code int) {
Expand Down

0 comments on commit 8cde9c9

Please sign in to comment.