AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 350 forks source link

Input type automatically converts the first letter of the input to uppercase #164

Closed Charliego3 closed 5 years ago

Charliego3 commented 5 years ago

As the title says, I type 'loveparadise_l' and automatically change to 'Loveparadise_l'

2018-11-27 16 29 45

orymate commented 5 years ago

You forgot to add a code snippet for reproducing the issue.

I suppose, you copied this line from the example, which is responsible for transforming the input to Title Case.

        Transform: survey.Title,
Charliego3 commented 5 years ago

Sorry, I did forget to add the code.

func main() {

    answers := struct {
        Address string `survey:"address"`
        Env     string `survey:"environment"`
    }{}

    var qs = []*survey.Question{
        {
            Name:      "address",
            Prompt:    &survey.Input{Message: "What is the withdrawal address?"},
            Validate:  survey.Required,
            Transform: survey.Title,
        },
        {
            Name: "environment",
            Prompt: &survey.Select{
                Message: "Choose a environment:",
                Options: []string{"zbg"},
                Default: "zbg",
            },
        },
    }

    // perform the questions
    err := survey.Ask(qs, &answers)
    if err != nil {
        log.Println(errorP, err.Error(), end)
        return
    }
    fmt.Println(answers)
}

And I delete Transform: survey.Title, then is ok. Thanks for your help.

AlecAivazis commented 5 years ago

I'm happy you were able to figure this out @whimthen! Thanks @orymate for helping out