1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
diff --git a/registry/prompt.go b/registry/prompt.go
index dfa47cecf78e26359c0cb42b4eb4057421f4a77e..62317c2a2a984efbe5413f2e2a8e93b581c12d22 100644
--- a/registry/prompt.go
+++ b/registry/prompt.go
@@ -84,6 +84,18 @@ 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,
@@ -103,6 +115,7 @@ }
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 {
@@ -115,25 +128,29 @@ }
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() string {
- return fmt.Sprintf("%v", vv)
+ m[k] = func() interface{} {
+ return 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]
}
|