Skip to content

Commit a90690f

Browse files
committed
there is one more option of formatting - c(C)
1 parent 037e3a2 commit a90690f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

formatter.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,13 @@ func getItemAsStr(item *any, itemFormat *string) string {
583583
* 3. {0:c:Kebab}, {0:c:kebab}, {0:c:KEBAB} - 3 ways of Kebab formatting: first lower case with start Capital letter
584584
* 4. {0:c:Snake}, {0:c:snake}, {0:c:SNAKE} - 3 ways of Snake formatting: first lower case with start Capital letter
585585
*/
586+
formatSubParts := strings.Split(*itemFormat, ":")
587+
if len(formatSubParts) > 1 {
588+
format, firstSymbolCase, textCase := GetFormattingStyleOptions(formatSubParts[1])
589+
val := (*item).([]interface{})
590+
itemStr := val[0].(string)
591+
return SetStyle(&itemStr, format, firstSymbolCase, textCase)
592+
}
586593
default:
587594
base = 10
588595
}

formatter_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,21 @@ func TestFormatWithArgFormatting(t *testing.T) {
233233
args: []any{[]any{"s1", "s2", "s3"}},
234234
expected: "This is a list(slice) test: s1 s2 s3",
235235
},
236+
"docs_with_func_to_snake": {
237+
template: "This docs contains description of a \"{0:c:snake}\" function",
238+
args: []any{[]any{"callSoapService"}},
239+
expected: "This docs contains description of a \"call_soap_service\" function",
240+
},
241+
"docs_with_func_to_upper_case_snake": {
242+
template: "This docs contains depends on a \"{0:c:SNAKE}\" constant",
243+
args: []any{[]any{"ReadTimeout"}},
244+
expected: "This docs contains depends on a \"READ_TIMEOUT\" constant",
245+
},
246+
"notes-about-kebab": {
247+
template: "Nowadays we've got a very strange style it looks in a following manner \"{0:C:kebab}\" and called \"kebab\"",
248+
args: []any{[]any{"veryVeryStrange"}},
249+
expected: "Nowadays we've got a very strange style it looks in a following manner \"very-very-strange\" and called \"kebab\"",
250+
},
236251
} {
237252
// Run test here
238253
t.Run(name, func(t *testing.T) {

0 commit comments

Comments
 (0)