Skip to content

Commit 8ff4827

Browse files
authored
feat: Support TitleCaseEnabled option for tags (#39)
1 parent 113ae25 commit 8ff4827

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

‎cmd/cmd.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ func generateTCard(streams IOStreams, contentPath, outPath string, tpl image.Ima
180180
}
181181

182182
for _, t := range fm.Tags[:lim] {
183-
tags = append(tags, strings.Title(t))
183+
if *cnf.Tags.TitleCaseEnabled {
184+
t = strings.Title(t)
185+
}
186+
tags = append(tags, t)
184187
}
185188

186189
/* Title */

‎example/default.config.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ info:
2929
tags:
3030
enabled: true
3131
limit: 0
32+
titleCaseEnabled: true
3233
start:
3334
px: 1025
3435
py: 451

‎pkg/config/config.go‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ type MultiLineTextOption struct {
3232

3333
type BoxTextsOption struct {
3434
TextOption
35-
BgHexColor string `json:"bgHexColor,omitempty"`
36-
BoxPadding *Padding `json:"boxPadding,omitempty"`
37-
BoxSpacing *int `json:"boxSpacing,omitempty"`
38-
BoxAlign box.Align `json:"boxAlign,omitempty"`
39-
Enabled *bool `json:"enabled,omitempty"`
40-
Limit int `json:"limit,omitempty"`
35+
BgHexColor string `json:"bgHexColor,omitempty"`
36+
BoxPadding *Padding `json:"boxPadding,omitempty"`
37+
BoxSpacing *int `json:"boxSpacing,omitempty"`
38+
BoxAlign box.Align `json:"boxAlign,omitempty"`
39+
Enabled *bool `json:"enabled,omitempty"`
40+
Limit int `json:"limit,omitempty"`
41+
TitleCaseEnabled *bool `json:"titleCaseEnabled,omitempty"`
4142
}
4243

4344
type Point struct {

‎pkg/config/default.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ var defaultCnf = DrawingConfig{
3535
TimeFormat: "Jan 2",
3636
},
3737
Tags: &BoxTextsOption{
38-
Enabled: ptrBool(true),
39-
Limit: 0,
38+
Enabled: ptrBool(true),
39+
Limit: 0,
40+
TitleCaseEnabled: ptrBool(true),
4041
TextOption: TextOption{
4142
Start: &Point{X: 1025, Y: 451},
4243
FgHexColor: "#FFFFFF",
@@ -106,6 +107,9 @@ func defaultTags(bto *BoxTextsOption) {
106107
if bto.Limit < 0 {
107108
bto.Limit = defaultCnf.Tags.Limit
108109
}
110+
if bto.TitleCaseEnabled == nil {
111+
bto.TitleCaseEnabled = defaultCnf.Tags.TitleCaseEnabled
112+
}
109113

110114
setArgsAsDefaultTextOption(&bto.TextOption, &defaultCnf.Tags.TextOption)
111115

@@ -152,5 +156,5 @@ func ptrInt(x int) *int {
152156
}
153157

154158
func ptrBool(b bool) *bool {
155-
return &b
159+
return &b
156160
}

0 commit comments

Comments
 (0)