func ApplyArguments(field *pb.Field, args ...*pb.Argument) error {
	if field == nil {
		return errors.New("field was nil")
	} else if field.GetParam() == nil {
		return fmt.Errorf("field %s does not have a parameter", field.Key)
	} else if len(args) < 1 && field.GetParam().GetDefault() == nil {
		return errors.New("an argument must be specified if no default is given")
	} else if len(args) < 1 {
		return applyDefault(field)
	} else if len(args) == 1 && len(field.GetParam().Pattern) == 0 {
		return simpleArgApply(field, args[0])
	} else if len(args) > 1 && len(field.GetParam().Pattern) == 0 {
		return errors.New("may only use multiple arguments if a string template is provided")
	}
	argVals := make([]interface{}, len(args))
	for i, v := range args {
		switch val := v.GetValue().(type) {
		case *pb.Argument_Number:
			argVals[i] = val.Number
		case *pb.Argument_Str:
			argVals[i] = val.Str
		case *pb.Argument_Boolean:
			argVals[i] = val.Boolean
		}
	}
	val := fmt.Sprintf(field.GetParam().Pattern, argVals...)
	field.Value = &pb.Field_Str{Str: val}
	return nil
}
ApplyArguments takes the given arguments and uses them to satisfy a field parameter. If a single argument and no
formatting pattern are given the single argument is used as the field value. Otherwise the arguments will be used as
arguments to Printf with the formatting string as the pattern.
package data
import (
	"bufio"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"strings"
	pb "rsprd.com/spread/pkg/spreadproto"
)
func InteractiveArgs(r io.ReadCloser, w io.Writer, field *pb.Field, required bool) error {
	param := field.GetParam()
	defaultVal := param.GetDefault()
	if required && defaultVal != nil {
		return nil
	}
	fmt.Fprintln(w, "Name: ", param.Name)
	fmt.Fprintln(w, "Prompt: ", param.Prompt)
	fmt.Fprint(w, "Input: ", displayDefault(defaultVal))
	reader := bufio.NewReader(r)
	text, err := reader.ReadString('\n')
	if err != nil {
		return err
	}
	args := []*pb.Argument{defaultVal}
	if len(text) > 1 {
		_, str := field.GetValue().(*pb.Field_Str)
		args, err = ParseArguments(text[:len(text)-1], str)
		if err != nil {
			return err
		}
	}
	return ApplyArguments(field, args...)
}
func displayDefault(d *pb.Argument) string {
	if d.GetValue() == nil {
		return ""
	}
	var out interface{}
	switch val := d.GetValue().(type) {
	case *pb.Argument_Number:
		out = val.Number
	case *pb.Argument_Str:
		out = val.Str
	case *pb.Argument_Boolean:
		out = val.Boolean
	}
	return fmt.Sprintf("(%v) ", out)
}
func AddParamToDoc(doc *pb.Document, target *SRI, param *pb.Parameter) error {
	if !target.IsField() {
		return errors.New("passed SRI is not a field")
	}
	field, err := GetFieldFromDocument(doc, target.Field)
	if err != nil {
		return err
	}
	field.Param = param
	return nil
}