Skip to content

Commit f49f929

Browse files
authored
fix: proper ToBashArg() for IPID (#250)
* cli: fix scw instance update ip [APIGW-1491]
1 parent 49d4c25 commit f49f929

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

strcase/bash_arg.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ package strcase
22

33
import "strings"
44

5+
var customBashNames = map[string]string{
6+
"IPID": "ip-id",
7+
}
8+
59
// ToBashArg returns the Bash public name of the given string.
610
func ToBashArg(s string) string {
711
s = ToPublicGoName(s)
12+
if customBashName, exists := customBashNames[s]; exists {
13+
return customBashName
14+
}
815
for _, initialism := range customInitialisms {
916
// catch this kind of pattern: ExampleIDs ==> ExampleIds ==> example-ids
1017
s = strings.Replace(s, initialism[0], strings.Title(strings.ToLower(initialism[0])), -1)

strcase/strcase_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestAllStrCases(t *testing.T) {
4646
{"my_resource_ids", "MyResourceIDs", "myResourceIDs", "my-resource-ids"},
4747
{"acids", "Acids", "acids", "acids"},
4848
{"secret-key", "SecretKey", "secretKey", "secret-key"},
49+
{"ip-id", "IPID", "ipID", "ip-id"},
4950
}
5051
for _, test := range tests {
5152
got := ToPublicGoName(test.name)

0 commit comments

Comments
 (0)