removed survey

This commit is contained in:
Lea Anthony
2019-02-19 19:37:45 +11:00
parent 94e9447e1c
commit b18f04b30d
5 changed files with 15 additions and 64 deletions

View File

@@ -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"`

View File

@@ -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])

View File

@@ -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 = `