mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 03:09:17 +08:00
removed survey
This commit is contained in:
parent
94e9447e1c
commit
b18f04b30d
@ -118,37 +118,6 @@ func (ph *ProjectHelper) NewProjectOptions() *ProjectOptions {
|
||||
return &result
|
||||
}
|
||||
|
||||
// // SelectQuestion creates a new select type question for Survey
|
||||
// func SelectQuestion(name, message string, options []string, defaultValue string, required bool) *survey.Question {
|
||||
// result := survey.Question{
|
||||
// Name: name,
|
||||
// Prompt: &survey.Select{
|
||||
// Message: message,
|
||||
// Options: options,
|
||||
// Default: defaultValue,
|
||||
// },
|
||||
// }
|
||||
// if required {
|
||||
// result.Validate = survey.Required
|
||||
// }
|
||||
// return &result
|
||||
// }
|
||||
|
||||
// InputQuestion creates a new input type question for Survey
|
||||
// func InputQuestion(name, message string, defaultValue string, required bool) *survey.Question {
|
||||
// result := survey.Question{
|
||||
// Name: name,
|
||||
// Prompt: &survey.Input{
|
||||
// Message: message + ":",
|
||||
// Default: defaultValue,
|
||||
// },
|
||||
// }
|
||||
// if required {
|
||||
// result.Validate = survey.Required
|
||||
// }
|
||||
// return &result
|
||||
// }
|
||||
|
||||
// ProjectOptions holds all the options available for a project
|
||||
type ProjectOptions struct {
|
||||
Name string `json:"name"`
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// Prompt asks the user for a value
|
||||
func Prompt(question string, defaultValue ...string) string {
|
||||
var answer string
|
||||
haveDefault := len(defaultValue) > 0
|
||||
haveDefault := len(defaultValue) > 0 && defaultValue[0] != ""
|
||||
|
||||
if haveDefault {
|
||||
question = fmt.Sprintf("%s (%s)", question, defaultValue[0])
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gopkg.in/AlecAivazis/survey.v1"
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
@ -82,9 +81,6 @@ func (s *SystemHelper) BackupConfig() (string, error) {
|
||||
|
||||
func (s *SystemHelper) setup() error {
|
||||
|
||||
// Answers. We all need them.
|
||||
answers := &SystemConfig{}
|
||||
|
||||
// Try to load current values - ignore errors
|
||||
config, err := s.LoadConfig()
|
||||
defaultName := ""
|
||||
@ -93,31 +89,10 @@ func (s *SystemHelper) setup() error {
|
||||
defaultName = config.Name
|
||||
defaultEmail = config.Email
|
||||
}
|
||||
// Questions
|
||||
var simpleQs = []*survey.Question{
|
||||
{
|
||||
Name: "Name",
|
||||
Prompt: &survey.Input{
|
||||
Message: "What is your name:",
|
||||
Default: defaultName,
|
||||
},
|
||||
Validate: survey.Required,
|
||||
},
|
||||
{
|
||||
Name: "Email",
|
||||
Prompt: &survey.Input{
|
||||
Message: "What is your email address:",
|
||||
Default: defaultEmail,
|
||||
},
|
||||
Validate: survey.Required,
|
||||
},
|
||||
}
|
||||
|
||||
// ask the questions
|
||||
err = survey.Ask(simpleQs, answers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
systemConfig := make(map[string]string)
|
||||
systemConfig["name"] = PromptRequired("What is your name", defaultName)
|
||||
systemConfig["email"] = PromptRequired("What is your email address", defaultEmail)
|
||||
|
||||
// Create the directory
|
||||
err = s.fs.MkDirs(s.wailsSystemDir)
|
||||
@ -125,12 +100,21 @@ func (s *SystemHelper) setup() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save
|
||||
configData, err := json.Marshal(&systemConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(s.wailsSystemConfig, configData, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println()
|
||||
s.log.White("Wails config saved to: " + s.wailsSystemConfig)
|
||||
s.log.White("Feel free to customise these settings.")
|
||||
fmt.Println()
|
||||
|
||||
return answers.Save(s.wailsSystemConfig)
|
||||
return nil
|
||||
}
|
||||
|
||||
const introText = `
|
||||
|
1
go.mod
1
go.mod
@ -16,5 +16,4 @@ require (
|
||||
github.com/pkg/errors v0.8.1 // indirect
|
||||
github.com/sirupsen/logrus v1.3.0
|
||||
github.com/wailsapp/webview v0.2.5
|
||||
gopkg.in/AlecAivazis/survey.v1 v1.8.2
|
||||
)
|
||||
|
3
go.sum
3
go.sum
@ -362,6 +362,7 @@ github.com/wailsapp/webview v0.2.5 h1:/VacryPEUeMBb2VHHOjpoIze6ki8tW3qYX04MnI0b7
|
||||
github.com/wailsapp/webview v0.2.5/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
@ -449,8 +450,6 @@ golang.org/x/tools v0.0.0-20190131142011-8dbcc66f33bb/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20190206221403-44bcb96178d3 h1:M9mD7d4inzK0+YbTneZEs9Y+q1B1zLv8YxJDJ6hFgnY=
|
||||
golang.org/x/tools v0.0.0-20190206221403-44bcb96178d3/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/AlecAivazis/survey.v1 v1.8.2 h1:168gU32e10Xm6NzttCL75XlCQF+nNh0VWuRU80u1GIw=
|
||||
gopkg.in/AlecAivazis/survey.v1 v1.8.2/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA=
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
Loading…
Reference in New Issue
Block a user