Skip to content

Commit

Permalink
Added InitChain to code-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Nov 3, 2024
1 parent c4a11e5 commit a8ee8ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/dev_tools/goMaker/types/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func getFuncMap() template.FuncMap {
firstLower := func(s string) string { return FirstLower(s) }
firstUpper := func(s string) string { return FirstUpper(s) }
toLowerPlural := func(s string) string { return Lower(Plural(s)) }
or := func(a, b bool) bool { return a || b }
return template.FuncMap{
"toSingular": toSingular,
"toProper": toProper,
Expand All @@ -50,5 +51,6 @@ func getFuncMap() template.FuncMap {
"toLower": toLower,
"firstLower": firstLower,
"firstUpper": firstUpper,
"or": or,
}
}
4 changes: 4 additions & 0 deletions src/dev_tools/goMaker/types/types_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ func (s *Structure) NeedsChain() bool {
return !strings.Contains(s.Attributes, "noChain")
}

func (s *Structure) InitChain() bool {
return !s.NeedsChain() && strings.Contains(s.Attributes, "initChain")
}

func (s *Structure) NeedsFetch() bool {
return !strings.Contains(s.Attributes, "noFetch")
}
Expand Down
5 changes: 3 additions & 2 deletions src/dev_tools/goMaker/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ func FirstLower(s string) string {
func Plural(s string) string {
if strings.HasSuffix(s, "s") {
return s
}
if strings.HasSuffix(s, "x") {
} else if strings.HasSuffix(s, "x") {
return s + "es"
} else if strings.HasSuffix(s, "y") {
return s + "ies"
}
return s + "s"
}
Expand Down

0 comments on commit a8ee8ba

Please sign in to comment.