diff --git a/registry/prompt.go b/registry/prompt.go index 62317c2a2a984efbe5413f2e2a8e93b581c12d22..dfa47cecf78e26359c0cb42b4eb4057421f4a77e 100644 --- a/registry/prompt.go +++ b/registry/prompt.go @@ -84,18 +84,6 @@ Message: prompt.Message, Options: t, Help: prompt.Help, } - case bool: - p = &survey.Confirm{ - Message: prompt.Message, - Default: t, - Help: prompt.Help, - } - case string: - p = &survey.Input{ - Message: prompt.Message, - Default: t, - Help: prompt.Help, - } default: p = &survey.Input{ Message: prompt.Message, @@ -115,7 +103,6 @@ } type templatePrompts []templatePrompt -// ToMap converts a slice to templatePrompt into a suitable template context func (t templatePrompts) ToMap() map[string]interface{} { m := make(map[string]interface{}) for _, p := range t { @@ -128,29 +115,25 @@ } return m } -// ToFuncMap converts a slice of templatePrompt into a suitable template.FuncMap func (t templatePrompts) ToFuncMap() template.FuncMap { m := make(map[string]interface{}) for k, v := range t.ToMap() { vv := v // Enclosure - m[k] = func() interface{} { - return vv + m[k] = func() string { + return fmt.Sprintf("%v", vv) } } return m } -// Len is for sort.Sort func (t templatePrompts) Len() int { return len(t) } -// Less is for sort.Sort func (t templatePrompts) Less(i, j int) bool { return t[i].Key > t[j].Key } -// Swap is for sort.Sort func (t templatePrompts) Swap(i, j int) { t[i], t[j] = t[j], t[i] } diff --git a/registry/template_test.go b/registry/template_test.go index 019d3b15d71b62d03fae59c1d96ddab3d90a06e6..11f2d0f3548374aba8c3218c464e562af160d079 100644 --- a/registry/template_test.go +++ b/registry/template_test.go @@ -8,19 +8,14 @@ "testing" ) var ( - tmplContents = `{{title name}} {{if .bool}}{{.year}}{{end}}` - tmplTemplate = ` -name = "john olheiser" + tmplContents = `{{title name}} {{.year}}` + tmplTemplate = `name = "john olheiser" [year] -default = ${TMPL_TEST} # 2020 +default = ${TMPL_TEST} [package] -default = "pkg" - -[bool] -default = true -` +default = "pkg"` tmplGold = "John Olheiser 2020" tmplNewGold = "DO NOT OVERWRITE!" )