Skip to content

Commit 57d2a42

Browse files
committed
refactor: update optionalParamsOK as exported member
1 parent c84e958 commit 57d2a42

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

pkg/github/helper_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestOptionalParamOK(t *testing.T) {
162162

163163
// Test with string type assertion
164164
if _, isString := tc.expectedVal.(string); isString || tc.errorMsg == "parameter myParam is not of type string, is bool" {
165-
val, ok, err := optionalParamOK[string](request, tc.paramName)
165+
val, ok, err := OptionalParamOK[string](request, tc.paramName)
166166
if tc.expectError {
167167
require.Error(t, err)
168168
assert.Contains(t, err.Error(), tc.errorMsg)
@@ -177,7 +177,7 @@ func TestOptionalParamOK(t *testing.T) {
177177

178178
// Test with bool type assertion
179179
if _, isBool := tc.expectedVal.(bool); isBool || tc.errorMsg == "parameter myParam is not of type bool, is string" {
180-
val, ok, err := optionalParamOK[bool](request, tc.paramName)
180+
val, ok, err := OptionalParamOK[bool](request, tc.paramName)
181181
if tc.expectError {
182182
require.Error(t, err)
183183
assert.Contains(t, err.Error(), tc.errorMsg)
@@ -192,7 +192,7 @@ func TestOptionalParamOK(t *testing.T) {
192192

193193
// Test with float64 type assertion (for number case)
194194
if _, isFloat := tc.expectedVal.(float64); isFloat {
195-
val, ok, err := optionalParamOK[float64](request, tc.paramName)
195+
val, ok, err := OptionalParamOK[float64](request, tc.paramName)
196196
if tc.expectError {
197197
// This case shouldn't happen for float64 in the defined tests
198198
require.Fail(t, "Unexpected error case for float64")

pkg/github/pullrequests.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,35 @@ func UpdatePullRequest(client *github.Client, t translations.TranslationHelperFu
118118
update := &github.PullRequest{}
119119
updateNeeded := false
120120

121-
if title, ok, err := optionalParamOK[string](request, "title"); err != nil {
121+
if title, ok, err := OptionalParamOK[string](request, "title"); err != nil {
122122
return mcp.NewToolResultError(err.Error()), nil
123123
} else if ok {
124124
update.Title = github.Ptr(title)
125125
updateNeeded = true
126126
}
127127

128-
if body, ok, err := optionalParamOK[string](request, "body"); err != nil {
128+
if body, ok, err := OptionalParamOK[string](request, "body"); err != nil {
129129
return mcp.NewToolResultError(err.Error()), nil
130130
} else if ok {
131131
update.Body = github.Ptr(body)
132132
updateNeeded = true
133133
}
134134

135-
if state, ok, err := optionalParamOK[string](request, "state"); err != nil {
135+
if state, ok, err := OptionalParamOK[string](request, "state"); err != nil {
136136
return mcp.NewToolResultError(err.Error()), nil
137137
} else if ok {
138138
update.State = github.Ptr(state)
139139
updateNeeded = true
140140
}
141141

142-
if base, ok, err := optionalParamOK[string](request, "base"); err != nil {
142+
if base, ok, err := OptionalParamOK[string](request, "base"); err != nil {
143143
return mcp.NewToolResultError(err.Error()), nil
144144
} else if ok {
145145
update.Base = &github.PullRequestBranch{Ref: github.Ptr(base)}
146146
updateNeeded = true
147147
}
148148

149-
if maintainerCanModify, ok, err := optionalParamOK[bool](request, "maintainer_can_modify"); err != nil {
149+
if maintainerCanModify, ok, err := OptionalParamOK[bool](request, "maintainer_can_modify"); err != nil {
150150
return mcp.NewToolResultError(err.Error()), nil
151151
} else if ok {
152152
update.MaintainerCanModify = github.Ptr(maintainerCanModify)

pkg/github/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ func GetMe(client *github.Client, t translations.TranslationHelperFunc) (tool mc
113113
}
114114
}
115115

116-
// optionalParamOK is a helper function that can be used to fetch a requested parameter from the request.
116+
// OptionalParamOK is a helper function that can be used to fetch a requested parameter from the request.
117117
// It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong.
118-
func optionalParamOK[T any](r mcp.CallToolRequest, p string) (value T, ok bool, err error) {
118+
func OptionalParamOK[T any](r mcp.CallToolRequest, p string) (value T, ok bool, err error) {
119119
// Check if the parameter is present in the request
120120
val, exists := r.Params.Arguments[p]
121121
if !exists {

0 commit comments

Comments
 (0)