// SelectFromStrings ...
634
func SelectFromStrings(messageToPrint string, options []string) (string, error) {
	return SelectFromStringsFromReader(messageToPrint, options, os.Stdin)
}
1281451
func (f *Form) SelectValues(name string) ([]string, error) {
	if _, ok := f.fields[name]; ok {
		return f.fields[name], nil
	}
	return nil, errors.NewElementNotFound("No input found with name '%s'.", name)
}
387254
func LevelFromString(lvl string) level {
	// Determine if lvl includes "level"
	lvl = strings.ToLower(lvl)
	if len(lvl) > 4 && lvl[0:5] != "level" {
		lvl = "level_" + lvl
	} else if len(lvl) < 5 {
		lvl = "level_" + lvl
	}
	for num, llvl := range levels {
		if lvl == strings.ToLower(llvl) {
			return level(num)
		}
	}
	return LEVEL_PRINT
}
191893
func FiltersFromString(newRegex string) (map[string]*regexp.Regexp, error) {
	if newRegex == "" {
		return nil, nil
	}
	lines := strings.Split(newRegex, "\n")
	newFilters := make(map[string]*regexp.Regexp, len(lines))
	for _, line := range lines {
		lineParts := strings.SplitN(line, ":", 2)
		if len(lineParts) != 2 || lineParts[0] == "" || lineParts[1] == "" {
			return nil, errors.Errorf("Cannot parse line %s", line)
		}
		reg, err := regexp.Compile(lineParts[1])
		if err != nil {
			return nil, errors.Annotatef(err, "Cannot parse regex line %s", line)
		}
		newFilters[lineParts[0]] = reg
	}
	return newFilters, nil
}
651953
func FilterString(s []string, cb func(s string) bool) []string {
	results := []string{}

	for _, i := range s {
		result := cb(i)

		if result {
			results = append(results, i)
		}
	}

	return results
}
807918
func SelectFromStringsFromReaderWithDefault(messageToPrint string, defaultValue int, options []string, inputReader io.Reader) (string, error) {
	fmt.Printf("%s\n", messageToPrint)
	fmt.Println("Please select from the list:")
	for idx, anOption := range options {
		fmt.Printf("[%d] : %s\n", idx+1, anOption)
	}

	selectedOptionNum, err := AskForIntFromReaderWithDefault("(type in the option's number, then hit Enter)", defaultValue, inputReader)
	if err != nil {
		return "", err
	}

	if selectedOptionNum < 1 {
		return "", fmt.Errorf("invalid option: You entered a number less than 1")
	}
	if selectedOptionNum > int64(len(options)) {
		return "", fmt.Errorf("invalid option: You entered a number greater than the last option's number")
	}
	return options[selectedOptionNum-1], nil
}
123264
func SetValueFromString(f reflect.Value, value string) error {
	ft := f.Type()
	if ft.Kind() == reflect.Ptr {
		ft = ft.Elem()
		f = f.Elem()
	}

	switch ft.Kind() {
	case reflect.String:
		f.SetString(value)
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		{
			v, err := strconv.ParseInt(value, 0, ft.Bits())
			if err != nil {
				return newBadRequestf("%s is not int format", value)
			}
			f.SetInt(v)
		}
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		{
			v, err := strconv.ParseUint(value, 0, ft.Bits())
			if err != nil {
				return newBadRequestf("%s is not uint format", value)
			}
			f.SetUint(v)
		}
	case reflect.Float32, reflect.Float64:
		{
			v, err := strconv.ParseFloat(value, ft.Bits())
			if err != nil {
				return newBadRequestf("%s is not float format", value)
			}
			f.SetFloat(v)
		}
	case reflect.Bool:
		{
			v, err := strconv.ParseBool(value)
			if err != nil {
				return newBadRequestf("%s is not bool format", value)
			}
			f.SetBool(v)
		}
	case reflect.Slice, reflect.Array:
		elem := reflect.New(ft.Elem()).Elem()
		err := SetValueFromString(elem, value)
		if err != nil {
			return err
		}
		result := reflect.New(ft).Elem()
		result = reflect.Append(result, elem)
		f.Set(result)
	default:
		return fmt.Errorf("unsupported format %s", ft.Name())
	}

	return nil
}
340569
func (j *JsonQuery) ArrayOfStrings(s ...string) ([]string, error) {
	array, err := j.Array(s...)
	if err != nil {
		return []string{}, err
	}
	toReturn := make([]string, len(array))
	for index, val := range array {
		toReturn[index], err = stringFromInterface(val)
		if err != nil {
			return toReturn, err
		}
	}
	return toReturn, nil
}
1169547
func (c *Menu) SetOptionsFromStrings(opts []string) {
	var newOpts []MenuOption
	for _, v := range opts {
		newOpts = append(newOpts, *CreateOptionFromText(v))
	}
	c.SetOptions(newOpts)
	c.SetSelectedOption(c.GetOptionFromIndex(0))
}
1323839
func (t *TemplateManager) RenderFromString(w io.Writer, tplSrc string, data interface{}) error {
	stack := []*Template{}
	t.push(&stack, tplSrc, "_fromString")
	tpl, err := t.assemble(stack)
	if err != nil {
		return err
	}

	err = tpl.Execute(w, data)
	if err != nil {
		return err
	}

	return nil
}
1356328
func KiteFromString(s string) (*Kite, error) {
	if s == "" || s[0] != '/' {
		return nil, errors.New("invalid kite string")
	}

	fields := make([]string, 7)
	copy(fields, strings.SplitN(s[1:], "/", 7))

	return &Kite{
		Username:    fields[0],
		Environment: fields[1],
		Name:        fields[2],
		Version:     fields[3],
		Region:      fields[4],
		Hostname:    fields[5],
		ID:          fields[6],
	}, nil
}
81331
func containsString(values []string, element string) bool {
	for _, value := range values {
		if value == element {
			return true
		}
	}
	return false
}
817426
func (u *Unit) ValueFromString(str string) (*Value, error) {
	s := &Value{unit: u}

	if err := s.Set(str); err != nil {
		return nil, err
	}
	return s, nil
}
381754
func LoadFromString(sql string) (*DotSql, error) {
	buf := bytes.NewBufferString(sql)
	return Load(buf)
}
603656
func (p *LinearSVCParams) SetKindFromStrings(loss, penalty string) error {
	var ret error
	p.SolverType = 0
	// Loss validation
	if loss == "l1" {
	} else if loss == "l2" {
	} else {
		return fmt.Errorf("loss must be \"l1\" or \"l2\"")
	}

	// Penalty validation
	if penalty == "l2" {
		if loss == "l1" {
			if !p.Dual {
				ret = fmt.Errorf("Important: changed to dual form")
			}
			p.SolverType = L2R_L1LOSS_SVC_DUAL
			p.Dual = true
		} else {
			if p.Dual {
				p.SolverType = L2R_L2LOSS_SVC_DUAL
			} else {
				p.SolverType = L2R_L2LOSS_SVC
			}
		}
	} else if penalty == "l1" {
		if loss == "l2" {
			if p.Dual {
				ret = fmt.Errorf("Important: changed to primary form")
			}
			p.Dual = false
			p.SolverType = L1R_L2LOSS_SVC
		} else {
			return fmt.Errorf("Must have L2 loss with L1 penalty")
		}
	} else {
		return fmt.Errorf("Penalty must be \"l1\" or \"l2\"")
	}

	// Final validation
	if p.SolverType == 0 {
		return fmt.Errorf("Invalid parameter combination")
	}
	return ret
}
493327
func (bf *BFlags) AddStrings(name string) *Flag {
	flag := bf.addFlag(name, stringsType)
	if flag == nil {
		return nil
	}
	return flag
}
281533
func SelectorFromSet(ls Set) Selector {
	if ls == nil {
		return Everything()
	}
	items := make([]Selector, 0, len(ls))
	for field, value := range ls {
		items = append(items, &hasTerm{field: field, value: value})
	}
	if len(items) == 1 {
		return items[0]
	}
	return andTerm(items)
}