-
Notifications
You must be signed in to change notification settings - Fork 0
/
survey.go
108 lines (100 loc) · 2.65 KB
/
survey.go
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package input
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/ProstoyVadila/goproj/internal/config"
"github.com/ProstoyVadila/goproj/internal/models"
)
// descriptionQuestion
var descriptionQuestion = &survey.Question{
Name: "Description",
Prompt: &survey.Input{
Message: "Description:",
Help: "You can set a small description for README.md in your new projct.",
},
}
var prefixHelp = `
This prefix will be added to package name in your future projects.
Example of prefix: github.com/<your_github_name>
`
var prefixQuestion = &survey.Question{
Name: "Prefix",
Prompt: &survey.Input{
Message: "Projects' global prefix: github.com/",
Help: prefixHelp,
},
}
// additionalQuestions variable is additional input questions
var additionalQsuestions = []*survey.Question{
{
Name: "Author",
Prompt: &survey.Input{
Message: "Tell me your name:",
Help: "It will be set in the LICENSE.",
},
Validate: survey.MaxLength(255),
},
{
Name: "Skip",
Prompt: &survey.MultiSelect{
Message: "Skip files/folders from generation:",
Options: []string{
"cmd/",
"pkg/",
"internal/",
"Makefile",
"Dockerfile",
".dockerignore",
".gitignore",
"README.md",
"LICENSE",
".env",
"main.go",
"go.mod",
},
PageSize: 12,
Help: "You can skip some default files and/or folders from generation fro this project.",
},
},
{
Name: "InitGit",
Prompt: &survey.Confirm{
Message: "Do you want generator to init git repo in this folder?",
Default: true,
},
},
{
Name: "InitVSCode",
Prompt: &survey.Confirm{
Message: "Do you want generator to open the new project in VS Code?",
Default: true,
},
},
}
func getPackageNameQuestion(confExists bool, confs ...*models.GlobalConfig) *survey.Question {
message := "Project (package) name:"
help := "For example: github/blabla/new_project"
if confExists && len(confs) != 0 {
message += " " + confs[0].Prefix
help = fmt.Sprintf("Your prefix %s will be added your project name", confs[0].Prefix)
}
return &survey.Question{
Name: "PackageName",
Prompt: &survey.Input{
Message: message,
Help: help,
},
}
}
// getConfigQuestion creates a question (type Confirm) about using GlobalConfig or not and provides it in the Question's Help.
func getConfigQuestion(conf *models.GlobalConfig) *survey.Question {
help := fmt.Sprintf("Your global config is located in the \"~/%s\" file. More info via \"goproj config --help\" command.\n", config.ConfigName)
return &survey.Question{
Name: "config",
Prompt: &survey.Confirm{
Message: "Do you want to use a global config?",
Help: conf.ShowString() + help,
Default: true,
},
}
}