Skip to content

Commit

Permalink
catch cases with -
Browse files Browse the repository at this point in the history
  • Loading branch information
solrac97gr committed Aug 31, 2024
1 parent c3ca18b commit 9c4d87c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions folders/folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ func (f *Folders) CreateFolderStructure(projectName string, subAppName []string)
return err

}
err = f.CreateFolder(projectName + "/pkg/factory")
if err != nil {
return err
}
err = f.CreateFolder(projectName + "/pkg/server")
if err != nil {
return err
}

for _, route := range subAppName {
var err error
err = f.CreateFolder(projectName + "/internal/" + route)
Expand Down
Binary file modified main
Binary file not shown.
36 changes: 36 additions & 0 deletions utils/name_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ func Capitalize(s string) string {
if len(s) == 0 {
return s
}
if containsDash(s) {
return ProcessCases(s)
}
return strings.Title(strings.ToLower(s))
}

Expand All @@ -17,5 +20,38 @@ func Lowercase(s string) string {
if len(s) == 0 {
return s
}
if containsDash(s) {
return ProcessCasesToLowercase(s)
}
return strings.ToLower(s)
}

// Process Cases new-package -> NewPackage
func ProcessCases(s string) string {
if len(s) == 0 {
return s
}
s = strings.Replace(s, "-", " ", -1)
s = strings.Title(s)
s = strings.Replace(s, " ", "", -1)
return s
}

// ProcessCasesToLowercase new-package -> newPackage
func ProcessCasesToLowercase(s string) string {
if len(s) == 0 {
return s
}
s = strings.Replace(s, "-", " ", -1)
s = strings.Title(s)
s = strings.Replace(s, " ", "", -1)
return strings.ToLower(s)
}

// Contains a "-"
func containsDash(s string) bool {
if strings.Contains(s, "-") {
return true
}
return false
}

0 comments on commit 9c4d87c

Please sign in to comment.