Skip to content

Commit 0c8980d

Browse files
committed
fixing cli message
1 parent b37be61 commit 0c8980d

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

internal/ghmcp/server.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,20 +463,22 @@ func (t *bearerAuthTransport) RoundTrip(req *http.Request) (*http.Response, erro
463463
}
464464

465465
// cleanToolsets handles special toolset keywords in the enabled toolsets list:
466-
// Duplicates are removed from the result.
466+
// - Duplicates are removed from the result.
467+
// - Removes whitespaces
467468
// - "all": Returns ["all"] immediately, ignoring all other toolsets (unless dynamicToolsets is true)
468469
// - "default": Replaces with the actual default toolset IDs from GetDefaultToolsetIDs()
469470
// When dynamicToolsets is true, filters out "all" from the enabled toolsets.
470471
func cleanToolsets(enabledToolsets []string, dynamicToolsets bool) []string {
471472
seen := make(map[string]bool)
472473
result := make([]string, 0, len(enabledToolsets))
473474

474-
// Add non-default toolsets, removing duplicates
475+
// Add non-default toolsets, removing duplicates and trimming whitespace
475476
for _, toolset := range enabledToolsets {
476-
if !seen[toolset] {
477-
seen[toolset] = true
478-
if toolset != github.ToolsetMetadataDefault.ID && toolset != github.ToolsetMetadataAll.ID {
479-
result = append(result, toolset)
477+
trimmed := strings.TrimSpace(toolset)
478+
if !seen[trimmed] {
479+
seen[trimmed] = true
480+
if trimmed != github.ToolsetMetadataDefault.ID && trimmed != github.ToolsetMetadataAll.ID {
481+
result = append(result, trimmed)
480482
}
481483
}
482484
}

internal/ghmcp/server_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,33 @@ func TestTransformSpecialToolsets(t *testing.T) {
185185
"users",
186186
},
187187
},
188+
// Whitespace test cases
189+
{
190+
name: "whitespace check- leading and trailing whitespace on regular toolsets",
191+
input: []string{" actions ", " gists ", "notifications"},
192+
dynamicToolsets: false,
193+
expected: []string{"actions", "gists", "notifications"},
194+
},
195+
{
196+
name: "whitespace check - default toolset",
197+
input: []string{" actions ", " default ", "notifications"},
198+
dynamicToolsets: false,
199+
expected: []string{
200+
"actions",
201+
"notifications",
202+
"context",
203+
"repos",
204+
"issues",
205+
"pull_requests",
206+
"users",
207+
},
208+
},
209+
{
210+
name: "whitespace check - all toolset",
211+
input: []string{" actions ", " gists ", "notifications", " all "},
212+
dynamicToolsets: false,
213+
expected: []string{"all"},
214+
},
188215
}
189216

190217
for _, tt := range tests {

pkg/github/tools.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,14 @@ func GenerateToolsetsHelp() string {
422422
availableTools := strings.Join(availableToolsLines, ",\n\t ")
423423

424424
toolsetsHelp := fmt.Sprintf("Comma-separated list of tool groups to enable (no spaces).\n"+
425-
"Default: %s\n"+
426-
"Available: %s\n", defaultTools, availableTools) +
427-
"To enable all tools, use \"all\"."
425+
"Available: %s\n", availableTools) +
426+
"Special toolset keywords:\n" +
427+
" - all: Enables all available toolsets\n" +
428+
fmt.Sprintf(" - default: Enables the default toolset configuration of:\n\t %s\n", defaultTools) +
429+
"Examples:\n" +
430+
" - --toolsets=actions,gists,notifications\n" +
431+
" - Default + additional: --toolsets=default,actions,gists\n" +
432+
" - All tools: --toolsets=all"
433+
428434
return toolsetsHelp
429435
}

0 commit comments

Comments
 (0)