// Execute shows the checklist to the user
Execute shows the checklist to the user
// Execute shows the checklist to the user
func (checklist Checklist) Execute() (result model.Result) {
	checkedItems := []string{}
	prompt := &survey.MultiSelect{
		Message: checklist.Message,
		Options: checklist.Items,
	}
	validator := func(val interface{}) error {
		if len(val.([]core.OptionAnswer)) != len(checklist.Items) {
			return fmt.Errorf("Please finish all tasks in order to continue")
		}
		return nil
	}
	survey.AskOne(prompt, &checkedItems, survey.WithValidator(validator))
	result.WasSuccessful = true
	result.Message = "all items ticked"
	return result
}
func ( checklist Checklist ) Execute ( ) ( result model . Result ) { checkedItems := [ ] string { } prompt := & survey . MultiSelect { Message : checklist . Message , Options : checklist . Items , } validator := func ( val interface { } ) error { if len ( val . ( [ ] core . OptionAnswer ) ) != len ( checklist . Items ) { return fmt . Errorf ( " " ) } return nil } survey . AskOne ( prompt , & checkedItems , survey . WithValidator ( validator ) ) result . WasSuccessful = true result . Message = " " return result }
Execute shows the checklist to the user
Execute shows the checklist to the user
// Validate that all items have been checked // FIXME: Sadly the once not selected get lost once the validation fails (see https://github.com/AlecAivazis/survey/issues/259)