initial commit

This commit is contained in:
2021-10-21 02:51:32 +02:00
commit d9c1c42150
30 changed files with 1617 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package interact
import (
survey "github.com/AlecAivazis/survey/v2"
"github.com/thoas/go-funk"
"ledo/app/modules/context"
)
func SelectMode(context *context.LedoContext, selectedMode string) (string, error) {
mode := context.Mode
if selectedMode == "" {
availableModes := mode.GetModes()
// the questions to ask
var qs = []*survey.Question{
{
Name: "providers",
Prompt: &survey.Select{
Message: "Select run mode",
PageSize: 10,
Options: funk.Keys(availableModes).([]string),
},
},
}
err := survey.Ask(qs, &selectedMode)
if err != nil {
return "", err
}
}
_, err := mode.SetMode(selectedMode)
return selectedMode, err
}