50 lines
758 B
Go
50 lines
758 B
Go
package cmd
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/manifoldco/promptui"
|
|
log "github.com/s00500/env_logger"
|
|
)
|
|
|
|
func promtString(name string) string {
|
|
validate := func(input string) error {
|
|
if input == "" {
|
|
return errors.New("empty string")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
prompt := promptui.Prompt{
|
|
Label: name,
|
|
Validate: validate,
|
|
}
|
|
|
|
result, err := prompt.Run()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func promtPassword(name string) string {
|
|
validate := func(input string) error {
|
|
if input == "" {
|
|
return errors.New("empty string")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
prompt := promptui.Prompt{
|
|
Label: name,
|
|
Validate: validate,
|
|
HideEntered: true,
|
|
}
|
|
|
|
result, err := prompt.Run()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
return result
|
|
}
|