Open siredmar opened 4 years ago
@siredmar I implemented the improvement proposed by your issue, which will also meet my needs.
@siredmar I implemented the improvement proposed by your issue, which will also meet my needs.
@chiaretto this solves the 'select all' part msntuoned in my example above. This is great, but that's not what i asked for Initialy. I need to be able to chain several multiselects and be able to exit each of them without selecting anything from the list.
@siredmar But that is already possible. To exit without selecting, just press Enter without selecting anything. To link more than one, just follow the example below.
package main
import (
"fmt"
"strings"
survey "github.com/AlecAivazis/survey/v2"
)
// the questions to ask
var multiQs = []*survey.Question{
{
Name: "country1",
Prompt: &survey.MultiSelect{
Message: "First Country :",
Options: []string{
"Afghanistan",
"Åland Islands",
"Albania",
"Algeria",
"American Samoa",
"AndorrA",
"Angola",
"Anguilla",
"Antarctica",
"Antigua and Barbuda",
"Argentina",
},
},
},{
Name: "country2",
Prompt: &survey.MultiSelect{
Message: "Second Country :",
Options: []string{
"Bahamas",
"Bahrain",
"Bangladesh",
"Barbados",
"Belarus",
"Belgium",
"Belize",
"Benin",
"Bermuda",
"Bhutan",
"Bolivia",
"Bosnia and Herzegovina",
"Botswana",
"Bouvet Island",
"Brazil",
"British Indian Ocean Territory",
"Brunei Darussalam",
"Bulgaria",
"Burkina Faso",
"Burundi",
},
},
},
}
func main() {
answers := []string{}
// ask the question
err := survey.Ask(multiQs, &answers)
if err != nil {
fmt.Println(err.Error())
return
}
// print the answers
fmt.Printf("Your chose: %s\n", strings.Join(answers, ", "))
}
Currently i am using this library for a little interactive too that calls another menu and so on. This means i need to navigate forward and backward my menu structure. The forward part is pretty straight forward, but backwards is not. For a normal Select it is trivial by defining an "Back" option in the survey and looking at the response. For the MultiSelect however currently i am adding the "Back" manually. But this "Back" element behaves just like all other. I have to select it via the space on my keyboard to leave the menu.
Therefore i am looking for some sort of a mixture of MultiSelect and Select It could look like this:
Is this already possible?