Skip to content

Commit

Permalink
Updated casing config options and added editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipJakab committed Jan 28, 2024
1 parent c699af2 commit 031f5db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Mapping struct {
var CurrentConfig *Config = nil

// set in ReadConfig
var loadedConfigLocation string = ""
var loadedConfigLocation = ""

// GetAndValidateConfig gets configuration from viper
func GetAndValidateConfig() (*Config, error) {
Expand All @@ -71,7 +71,7 @@ func GetAndValidateConfig() (*Config, error) {
config.ModelTemplate = joinIfRelative(config.PathBase, config.ModelTemplate)
config.OutputFolder = joinIfRelative(config.PathBase, config.OutputFolder)

if !contains(ValidCase, strings.ToLower(config.GeneratedFileCase)) {
if !contains(ValidCaseNormalized, strings.ToLower(config.GeneratedFileCase)) {
return nil, fmt.Errorf(" '%s' is not valid case (maybe GeneratedFileCase is missing)", config.GeneratedFileCase)
}

Expand Down
10 changes: 5 additions & 5 deletions src/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
const processorsFolder = "processors"
const modelsFolder = "models"

var ValidCaseNormalized = []string{"snakecase", "camelcase", "pascalcase"}

func Generate(routines []Routine, config *Config) error {
fileHashes, err := generateFileHashes(config.OutputFolder)
if err != nil {
Expand Down Expand Up @@ -278,15 +280,13 @@ func generateFileHashes(outputFolder string) (*map[string]string, error) {

}

var ValidCase = []string{"snake", "lcamel", "ucamel"}

func changeCase(str string, desiredCase string) string {
switch strings.ToLower(desiredCase) {
case "ucamel":
case "pascalCase":
return strcase.UpperCamelCase(str)
case "lcamel":
case "camelCase":
return strcase.LowerCamelCase(str)
case "snake":
case "snakeCase":
return strcase.SnakeCase(str)
default:

Expand Down

0 comments on commit 031f5db

Please sign in to comment.