initial commit
This commit is contained in:
32
app/modules/interact/mode.go
Normal file
32
app/modules/interact/mode.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user