AlecAivazis / survey

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

Now option answer can be transformed by this new fn #262

Closed satheshshiva closed 4 years ago

satheshshiva commented 4 years ago

Example,

{
        Name: "month",
        Prompt: &survey.Select{
            Message: "Month",
            Options: []string{
                "January - 01",
                "February - 02",
                "March - 03",
                "April - 04",
                "May - 05",
                "June - 06",
                "July - 07",
                "August - 08",
                "September - 09",
                "October - 10",
                "November - 11",
                "December - 12",

            },
        },
        Transform: survey.TransformOption(func(s core.OptionAnswer) core.OptionAnswer {
            s.Value = s.Value[len(s.Value)-2:]
            return s
        }),
    },
AlecAivazis commented 4 years ago

Looks great @satheshshiva! Mind adding some documentation for this transformer?