func (f IOFiller) Fill(form Form) (map[string]interface{}, error) {
	if len(form.Fields) == 0 {
		return map[string]interface{}{}, nil
	}
	if f.MaxTries == 0 {
		f.MaxTries = 3
	}
	if f.In == nil {
		f.In = os.Stdin
	}
	if f.Out == nil {
		f.Out = os.Stdout
	}
	if f.GetDefault == nil {
		f.GetDefault = DefaultFromEnv
	}
	fields := SortedFields(form.Fields)
	values := make(map[string]interface{}, len(fields))
	checkers := make([]schema.Checker, len(fields))
	allMandatory := true
	for i, field := range fields {
		checker, err := field.Checker()
		if err != nil {
			return nil, errgo.Notef(err, "invalid field %s", field.Name)
		}
		checkers[i] = checker
		allMandatory = allMandatory && field.Mandatory
	}
	if form.Title != "" {
		f.printf("%s\n", form.Title)
	}
	if allMandatory {
		f.printf("Press return to select a default value.\n")
	} else {
		f.printf("Press return to select a default value, or enter - to omit an entry.\n")
	}
	for i, field := range fields {
		v, err := f.promptLoop(field, checkers[i], allMandatory)
		if err != nil {
			return nil, errgo.Notef(err, "cannot complete form")
		}
		if v != nil {
			values[field.Name] = v
		}
	}
	return values, nil
}
// Fill implements Filler.Fill by writing the field information to
// f.Out, then reading input from f.In. If f.In is a terminal and the
// attribute is secret, echo will be disabled.
//
// Fill processes fields by first sorting them and then prompting for
// the value of each one in turn.
//
// The fields are sorted by first by group name. Those in the same group
// are sorted so that secret fields come after non-secret ones, finally
// the fields are sorted by description.
//
// Each field will be prompted for, then the returned value will be
// validated against the field's type. If the returned value does not
// validate correctly it will be prompted again up to MaxTries before
// giving up.
Fill implements Filler.Fill by writing the field information to
f.Out, then reading input from f.In. If f.In is a terminal and the
attribute is secret, echo will be disabled.

Fill processes fields by first sorting them and then prompting for
the value of each one in turn.

The fields are sorted by first by group name. Those in the same group
are sorted so that secret fields come after non-secret ones, finally
the fields are sorted by description.

Each field will be prompted for, then the returned value will be
validated against the field's type. If the returned value does not
validate correctly it will be prompted again up to MaxTries before
giving up.
// Fill implements Filler . Fill by writing the field information to // f . Out then reading input from f . In . If f . In is a terminal and the // attribute is secret echo will be disabled . // // Fill processes fields by first sorting them and then prompting for // the value of each one in turn . // // The fields are sorted by first by group name . Those in the same group // are sorted so that secret fields come after non - secret ones finally // the fields are sorted by description . // // Each field will be prompted for then the returned value will be // validated against the field ' s type . If the returned value does not // validate correctly it will be prompted again up to MaxTries before // giving up .
func (f IOFiller) Fill(form Form) (map[string]interface{}, error) {
	if len(form.Fields) == 0 {
		return map[string]interface{}{}, nil
	}
	if f.MaxTries == 0 {
		f.MaxTries = 3
	}
	if f.In == nil {
		f.In = os.Stdin
	}
	if f.Out == nil {
		f.Out = os.Stdout
	}
	if f.GetDefault == nil {
		f.GetDefault = DefaultFromEnv
	}
	fields := SortedFields(form.Fields)
	values := make(map[string]interface{}, len(fields))
	checkers := make([]schema.Checker, len(fields))
	allMandatory := true
	for i, field := range fields {
		checker, err := field.Checker()
		if err != nil {
			return nil, errgo.Notef(err, "invalid field %s", field.Name)
		}
		checkers[i] = checker
		allMandatory = allMandatory && field.Mandatory
	}
	if form.Title != "" {
		f.printf("%s\n", form.Title)
	}
	if allMandatory {
		f.printf("Press return to select a default value.\n")
	} else {
		f.printf("Press return to select a default value, or enter - to omit an entry.\n")
	}
	for i, field := range fields {
		v, err := f.promptLoop(field, checkers[i], allMandatory)
		if err != nil {
			return nil, errgo.Notef(err, "cannot complete form")
		}
		if v != nil {
			values[field.Name] = v
		}
	}
	return values, nil
}
func ( f IOFiller ) Fill ( form Form ) ( map [ string ] interface { } , error ) { if len ( form . Fields ) == 0 { return map [ string ] interface { } { } , nil } if f . MaxTries == 0 { f . MaxTries = 3 } if f . In == nil { f . In = os . Stdin } if f . Out == nil { f . Out = os . Stdout } if f . GetDefault == nil { f . GetDefault = DefaultFromEnv } fields := SortedFields ( form . Fields ) values := make ( map [ string ] interface { } , len ( fields ) ) checkers := make ( [ ] schema . Checker , len ( fields ) ) allMandatory := true for i , field := range fields { checker , err := field . Checker ( ) if err != nil { return nil , errgo . Notef ( err , " " , field . Name ) } checkers [ i ] = checker allMandatory = allMandatory && field . Mandatory } if form . Title != " " { f . printf ( " \n " , form . Title ) } if allMandatory { f . printf ( " \n " ) } else { f . printf ( " \n " ) } for i , field := range fields { v , err := f . promptLoop ( field , checkers [ i ] , allMandatory ) if err != nil { return nil , errgo . Notef ( err , " " ) } if v != nil { values [ field . Name ] = v } } return values , nil }
Fill implements Filler.Fill by writing the field information to
f.Out, then reading input from f.In.
Fill implements Filler . Fill by writing the field information to f . Out then reading input from f . In .