Add special case for 'Crud', and transform enum and struct type names

This commit is contained in:
2023-01-07 14:54:04 -08:00
parent c6b51b4705
commit df0dc254c3
3 changed files with 37 additions and 40 deletions

View File

@@ -71,6 +71,7 @@ func (s *StructParser) Parse() ([]Item, error) {
if slices.Contains(s.Skip, structName) {
continue
}
structName = s.TransformName(structName)
// If the line ends with "}", this is a struct with no fields
if strings.HasSuffix(line, "}\n") {
@@ -97,8 +98,9 @@ func (s *StructParser) Parse() ([]Item, error) {
enumName := enumRegex.FindStringSubmatch(line)[1]
if slices.Contains(s.Skip, enumName) {
continue
}
enumName = s.TransformName(enumName)
members, err := s.parseEnumMemebers()
if err != nil {
return nil, err
@@ -233,6 +235,8 @@ func TransformTypeGo(t string) string {
func TransformNameGo(s string) string {
out := ""
s = strings.ReplaceAll(s, "Crud", "CRUD")
splitName := strings.Split(s, "_")
for _, segment := range splitName {
switch segment {