feat(input): Full refacto of the user input system
This commit is contained in:
15
cmd/init.go
15
cmd/init.go
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/input"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -99,7 +100,7 @@ func runInitAction(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
log.Infof("Which kind of API do you want to init (possible values: %s)", strings.Join(possibleAPITypes, ", "))
|
||||
apiTypeName := helpers.APITypeNameInput()
|
||||
apiTypeName := input.APITypeName(true)
|
||||
|
||||
log.Debugf("Using api type : %s", string(apiTypeName))
|
||||
|
||||
@ -120,27 +121,27 @@ func runInitAction(cmd *cobra.Command, args []string) {
|
||||
|
||||
// ask project directory
|
||||
log.Info("Name of the project directory:")
|
||||
projectDirectory := helpers.AlphanumericalInput()
|
||||
projectDirectory := input.Alphanumerical(true)
|
||||
|
||||
// ask project name
|
||||
log.Info("Name of the project:")
|
||||
config.ProjectName = helpers.AlphanumericalAndSpaceInput()
|
||||
config.ProjectName = input.AlphanumericalAndSpace(true)
|
||||
|
||||
// ask project description
|
||||
log.Info("Description of the project:")
|
||||
config.ProjectDescription = helpers.StringInput()
|
||||
config.ProjectDescription = input.String(true)
|
||||
|
||||
// ask project contact
|
||||
config.ProjectContact = models.ProjectContactStruct{}
|
||||
|
||||
log.Info("Mail address of the developer team:")
|
||||
config.ProjectContact.Email = helpers.StringInput()
|
||||
config.ProjectContact.Email = input.Mail(true)
|
||||
|
||||
log.Info("Name of the team:")
|
||||
config.ProjectContact.Name = helpers.StringInput()
|
||||
config.ProjectContact.Name = input.String(true)
|
||||
|
||||
log.Info("URL of the contact informatino of the team:")
|
||||
config.ProjectContact.URL = helpers.StringInput()
|
||||
config.ProjectContact.URL = input.String(false)
|
||||
|
||||
// launch GetInitializeUserInput from selected api type
|
||||
log.Debug("Get user input for the selected API type")
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/input"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -55,7 +56,7 @@ func runUpgradeAction(cmd *cobra.Command, args []string) {
|
||||
if !acceptAll {
|
||||
log.Infof("Do you want to install the following version: %s", dependency.GetMinimumVersion())
|
||||
|
||||
answer := helpers.YesOrNoInput()
|
||||
answer := input.YesOrNo()
|
||||
if !answer {
|
||||
log.Warnf("Skipping installation of %s. Some part of the application might not be able to work correctly!", dependency.GetName())
|
||||
continue
|
||||
@ -74,10 +75,10 @@ func runUpgradeAction(cmd *cobra.Command, args []string) {
|
||||
if !acceptAll {
|
||||
log.Infof("Do you want to install %s in the directory %s ?", dependency.GetName(), installDirectory)
|
||||
|
||||
answer := helpers.YesOrNoInput()
|
||||
answer := input.YesOrNo()
|
||||
if !answer {
|
||||
log.Infof("Where do you want to install %s ?", dependency.GetName())
|
||||
installDirectory = helpers.PathInput()
|
||||
installDirectory = input.Path(true)
|
||||
}
|
||||
} else {
|
||||
log.Infof("Installing %s in the following directory: %s", dependency.GetName(), installDirectory)
|
||||
@ -93,12 +94,12 @@ func runUpgradeAction(cmd *cobra.Command, args []string) {
|
||||
return
|
||||
}
|
||||
log.Infof("Where do you want to install %s ?", dependency.GetName())
|
||||
installDirectory = helpers.PathInput()
|
||||
installDirectory = input.Path(true)
|
||||
}
|
||||
|
||||
log.Infof("%s", dependency.DescribeInstall(installDirectory))
|
||||
log.Info("Do you want to continue ?")
|
||||
answer := helpers.YesOrNoInput()
|
||||
answer := input.YesOrNo()
|
||||
if !answer {
|
||||
log.Warnf("Skipping installation of %s. Some part of the application might not be able to work correctly!", dependency.GetName())
|
||||
continue
|
||||
@ -114,7 +115,7 @@ func runUpgradeAction(cmd *cobra.Command, args []string) {
|
||||
|
||||
log.Infof("%s", dependency.DescribePostInstall(installDirectory))
|
||||
log.Info("Do you want to continue ?")
|
||||
answer = helpers.YesOrNoInput()
|
||||
answer = input.YesOrNo()
|
||||
if !answer {
|
||||
log.Warnf("Skipping post installation of %s. Some part of the application might not be able to work correctly!", dependency.GetName())
|
||||
continue
|
||||
|
Reference in New Issue
Block a user