gen/goav2gen/api.go
func extractCmdLineParams(a *gen.ActionParam, root string, seen map[string]*[]*gen.ActionParam, parentNotMandatory bool) []*gen.ActionParam {
	switch t := a.Type.(type) {
	case *gen.BasicDataType, *gen.EnumerableDataType, *gen.UploadDataType:
		dup := gen.ActionParam{
			Name:        a.Name,
			QueryName:   root,
			Description: a.Description,
			VarName:     a.VarName,
			Location:    a.Location,
			Type:        a.Type,
			Mandatory:   a.Mandatory && !parentNotMandatory, // yay for double negations!
			NonBlank:    a.NonBlank,
			Regexp:      a.Regexp,
			ValidValues: a.ValidValues,
			Min:         a.Min,
			Max:         a.Max,
		}
		return []*gen.ActionParam{&dup}
	case *gen.ArrayDataType:
		p := t.ElemType
		eq, ok := seen[p.Name]
		if !ok {
			eq = &[]*gen.ActionParam{}
			seen[p.Name] = eq
			*eq = extractCmdLineParams(p, root+"[]", seen, parentNotMandatory || !a.Mandatory)
		}
		return *eq
	case *gen.ObjectDataType:
		params := []*gen.ActionParam{}
		for _, f := range t.Fields {
			eq, ok := seen[f.Name]
			if !ok {
				eq = &[]*gen.ActionParam{}
				seen[f.Name] = eq
				*eq = extractCmdLineParams(f, fmt.Sprintf("%s[%s]", root, f.Name), seen, parentNotMandatory || !a.Mandatory)
			}
			params = append(params, *eq...)
		}
		return params
	}
	return nil
}
func extractCmdLineParams(a *gen.ActionParam, root string, seen map[string]*[]*gen.ActionParam, parentNotMandatory bool) []*gen.ActionParam {
	switch t := a.Type.(type) {
	case *gen.BasicDataType, *gen.EnumerableDataType, *gen.UploadDataType:
		dup := gen.ActionParam{
			Name:        a.Name,
			QueryName:   root,
			Description: a.Description,
			VarName:     a.VarName,
			Location:    a.Location,
			Type:        a.Type,
			Mandatory:   a.Mandatory && !parentNotMandatory, // yay for double negations!
			NonBlank:    a.NonBlank,
			Regexp:      a.Regexp,
			ValidValues: a.ValidValues,
			Min:         a.Min,
			Max:         a.Max,
		}
		return []*gen.ActionParam{&dup}
	case *gen.ArrayDataType:
		p := t.ElemType
		eq, ok := seen[p.Name]
		if !ok {
			eq = &[]*gen.ActionParam{}
			seen[p.Name] = eq
			*eq = extractCmdLineParams(p, root+"[]", seen, parentNotMandatory || !a.Mandatory)
		}
		return *eq
	case *gen.ObjectDataType:
		params := []*gen.ActionParam{}
		for _, f := range t.Fields {
			eq, ok := seen[f.Name]
			if !ok {
				eq = &[]*gen.ActionParam{}
				seen[f.Name] = eq
				*eq = extractCmdLineParams(f, fmt.Sprintf("%s[%s]", root, f.Name), seen, parentNotMandatory || !a.Mandatory)
			}
			params = append(params, *eq...)
		}
		return params
	}
	return nil
}
// extractCmdLineParams generates flags for the command line