Skip to content

Commit cb4daf6

Browse files
committed
[housekeeping] explicitly name urfavecli fns
1 parent 2cf82ae commit cb4daf6

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ handlers := map[string]HandlerCobra{
124124
}
125125

126126
// urfave/cli
127-
handlers := map[string]HandlerUrfaveCli{
127+
handlers := map[string]HandlerUrfaveCliV3{
128128
"AddGet": handler,
129129
"AddPost": handler,
130130
"HealthCheck": handler,
@@ -139,7 +139,7 @@ Bootstrap the root command:
139139
err := climate.BootstrapV3Cobra(rootCmd, *model, handlers)
140140

141141
// urfave/cli
142-
err := climate.BootstrapV3UrfaveCli(rootCmd, *model, handlers)
142+
err := climate.BootstrapV3UrfaveCliV3(rootCmd, *model, handlers)
143143
```
144144

145145
Continue adding more commands and/or execute:

urfavecli.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919
"github.com/urfave/cli/v3"
2020
)
2121

22-
type HandlerUrfaveCli func(opts *cli.Command, args []string, data HandlerData) error
22+
type HandlerUrfaveCliV3 func(opts *cli.Command, args []string, data HandlerData) error
2323

24-
func addParamsUrfaveCli(cmd *cli.Command, op *v3.Operation, handlerData *HandlerData) {
24+
func addParamsUrfaveCliV3(cmd *cli.Command, op *v3.Operation, handlerData *HandlerData) {
2525
var (
2626
queryParams []ParamMeta
2727
pathParams []ParamMeta
@@ -91,7 +91,7 @@ func addParamsUrfaveCli(cmd *cli.Command, op *v3.Operation, handlerData *Handler
9191
handlerData.CookieParams = cookieParams
9292
}
9393

94-
func addRequestBodyUrfaveCli(cmd *cli.Command, op *v3.Operation, handlerData *HandlerData) error {
94+
func addRequestBodyUrfaveCliV3(cmd *cli.Command, op *v3.Operation, handlerData *HandlerData) error {
9595
name, desc, required, err := makeRequestBody(op, handlerData)
9696
if err != nil {
9797
return err
@@ -106,7 +106,7 @@ func addRequestBodyUrfaveCli(cmd *cli.Command, op *v3.Operation, handlerData *Ha
106106
return nil
107107
}
108108

109-
func interpolatePathUrfaveCli(cmd *cli.Command, h *HandlerData) error {
109+
func interpolatePathUrfaveCliV3(cmd *cli.Command, h *HandlerData) error {
110110
// TODO: Extract commom
111111
for _, param := range h.PathParams {
112112
pattern, err := regexp.Compile(fmt.Sprintf("({%s})+", param.Name))
@@ -134,7 +134,7 @@ func interpolatePathUrfaveCli(cmd *cli.Command, h *HandlerData) error {
134134
}
135135

136136
// Bootstraps a cli.Command with the loaded model and a handler map
137-
func BootstrapV3UrfaveCli(rootCmd *cli.Command, model libopenapi.DocumentModel[v3.Document], handlers map[string]HandlerUrfaveCli) error {
137+
func BootstrapV3UrfaveCliV3(rootCmd *cli.Command, model libopenapi.DocumentModel[v3.Document], handlers map[string]HandlerUrfaveCliV3) error {
138138
cmdGroups := make(map[string][]*cli.Command)
139139

140140
for path, item := range model.Model.Paths.PathItems.FromOldest() {
@@ -150,8 +150,8 @@ func BootstrapV3UrfaveCli(rootCmd *cli.Command, model libopenapi.DocumentModel[v
150150
}
151151

152152
hData := HandlerData{Method: method, Path: path}
153-
addParamsUrfaveCli(&cmd, op, &hData)
154-
if err := addRequestBodyUrfaveCli(&cmd, op, &hData); err != nil {
153+
addParamsUrfaveCliV3(&cmd, op, &hData)
154+
if err := addRequestBodyUrfaveCliV3(&cmd, op, &hData); err != nil {
155155
return err
156156
}
157157

@@ -168,7 +168,7 @@ func BootstrapV3UrfaveCli(rootCmd *cli.Command, model libopenapi.DocumentModel[v
168168
cmd.Usage = op.Summary
169169
}
170170
cmd.Action = func(_ context.Context, cmd *cli.Command) error {
171-
if err := interpolatePathUrfaveCli(cmd, &hData); err != nil {
171+
if err := interpolatePathUrfaveCliV3(cmd, &hData); err != nil {
172172
return err
173173
}
174174

urfavecli_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/urfave/cli/v3"
99
)
1010

11-
func TestInterpolatePathUrfaveCli(t *testing.T) {
11+
func TestInterpolatePathUrfaveCliV3(t *testing.T) {
1212
hData := HandlerData{
1313
Method: "get",
1414
Path: "/path/{foo}/to/{bar}/with/{baz}/and/{quxx}/together",
@@ -44,13 +44,13 @@ func TestInterpolatePathUrfaveCli(t *testing.T) {
4444
},
4545
}
4646

47-
err := interpolatePathUrfaveCli(&cmd, &hData)
47+
err := interpolatePathUrfaveCliV3(&cmd, &hData)
4848
assert.NoError(t, err)
4949

5050
assert.Equal(t, hData.Path, "/path/yes/to/420/with/420.69/and/false/together")
5151
}
5252

53-
func assertCmdTreeUrfaveCli(t *testing.T, cmd *cli.Command, expected *cli.Command) {
53+
func assertCmdTreeUrfaveCliV3(t *testing.T, cmd *cli.Command, expected *cli.Command) {
5454
t.Logf("Checking command %s", cmd.Name)
5555

5656
assert.Equal(t, expected.Name, cmd.Name)
@@ -76,11 +76,11 @@ func assertCmdTreeUrfaveCli(t *testing.T, cmd *cli.Command, expected *cli.Comman
7676
}
7777

7878
for _, subCmd := range cmd.Commands {
79-
assertCmdTreeUrfaveCli(t, subCmd, expected.Command(subCmd.Name))
79+
assertCmdTreeUrfaveCliV3(t, subCmd, expected.Command(subCmd.Name))
8080
}
8181
}
8282

83-
func TestBootstrapV3UrfaveCli(t *testing.T) {
83+
func TestBootstrapV3UrfaveCliV3(t *testing.T) {
8484
model, err := LoadFileV3("api.yaml")
8585
assert.NoError(t, err)
8686

@@ -97,14 +97,14 @@ func TestBootstrapV3UrfaveCli(t *testing.T) {
9797
Name: "calc",
9898
Usage: "My Calc",
9999
}
100-
handlers := map[string]HandlerUrfaveCli{
100+
handlers := map[string]HandlerUrfaveCliV3{
101101
"AddGet": handler,
102102
"AddPost": handler,
103103
"HealthCheck": handler,
104104
"GetInfo": handler,
105105
}
106106

107-
err = BootstrapV3UrfaveCli(rootCmd, *model, handlers)
107+
err = BootstrapV3UrfaveCliV3(rootCmd, *model, handlers)
108108
assert.NoError(t, err)
109109

110110
var noAlias []string
@@ -163,7 +163,7 @@ func TestBootstrapV3UrfaveCli(t *testing.T) {
163163
},
164164
}
165165

166-
assertCmdTreeUrfaveCli(t, rootCmd, expectedCmd)
166+
assertCmdTreeUrfaveCliV3(t, rootCmd, expectedCmd)
167167

168168
assert.NoError(t, rootCmd.Run(
169169
context.Background(),

0 commit comments

Comments
 (0)