Skip to content

Commit 4b88930

Browse files
committed
code style
1 parent 1532f87 commit 4b88930

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

cmd/mcptools/commands/call.go

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,7 @@ func CallCmd() *cobra.Command {
3333
os.Exit(1)
3434
}
3535

36-
cmdArgs := args
37-
parsedArgs := []string{}
38-
entityName := ""
39-
40-
i := 0
41-
entityExtracted := false
42-
43-
for i < len(cmdArgs) {
44-
switch {
45-
case (cmdArgs[i] == FlagFormat || cmdArgs[i] == FlagFormatShort) && i+1 < len(cmdArgs):
46-
FormatOption = cmdArgs[i+1]
47-
i += 2
48-
case (cmdArgs[i] == FlagParams || cmdArgs[i] == FlagParamsShort) && i+1 < len(cmdArgs):
49-
ParamsString = cmdArgs[i+1]
50-
i += 2
51-
case !entityExtracted:
52-
entityName = cmdArgs[i]
53-
entityExtracted = true
54-
i++
55-
case cmdArgs[i] == FlagServerLogs:
56-
ShowServerLogs = true
57-
i++
58-
case cmdArgs[i] == FlagVerbose || cmdArgs[i] == FlagVerboseShort:
59-
Verbose = true
60-
i++
61-
default:
62-
parsedArgs = append(parsedArgs, cmdArgs[i])
63-
i++
64-
}
65-
}
36+
parsedArgs, entityName := parseCallArguments(args)
6637

6738
if entityName == "" {
6839
fmt.Fprintln(os.Stderr, "Error: entity name is required")
@@ -151,3 +122,38 @@ func CallCmd() *cobra.Command {
151122
},
152123
}
153124
}
125+
126+
// fix cyclomatic complexity
127+
func parseCallArguments(args []string) ([]string, string) {
128+
cmdArgs := args
129+
parsedArgs := []string{}
130+
entityName := ""
131+
132+
i := 0
133+
entityExtracted := false
134+
135+
for i < len(cmdArgs) {
136+
switch {
137+
case (cmdArgs[i] == FlagFormat || cmdArgs[i] == FlagFormatShort) && i+1 < len(cmdArgs):
138+
FormatOption = cmdArgs[i+1]
139+
i += 2
140+
case (cmdArgs[i] == FlagParams || cmdArgs[i] == FlagParamsShort) && i+1 < len(cmdArgs):
141+
ParamsString = cmdArgs[i+1]
142+
i += 2
143+
case !entityExtracted:
144+
entityName = cmdArgs[i]
145+
entityExtracted = true
146+
i++
147+
case cmdArgs[i] == FlagServerLogs:
148+
ShowServerLogs = true
149+
i++
150+
case cmdArgs[i] == FlagVerbose || cmdArgs[i] == FlagVerboseShort:
151+
Verbose = true
152+
i++
153+
default:
154+
parsedArgs = append(parsedArgs, cmdArgs[i])
155+
i++
156+
}
157+
}
158+
return parsedArgs, entityName
159+
}

cmd/mcptools/commands/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
ParamsString string
3737
// ShowServerLogs is a flag to show server logs.
3838
ShowServerLogs bool
39-
// Show http verbose info.
39+
// Verbose show http verbose info.
4040
Verbose bool
4141
)
4242

cmd/mcptools/commands/trace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func generateTraceID() [16]byte {
1414
var traceID [16]byte
15-
rand.Read(traceID[:])
15+
_, _ = rand.Read(traceID[:])
1616
return traceID
1717
}
1818

cmd/mcptools/commands/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
// Version information placeholder.
1111
var Version = "dev"
1212

13-
// getHomeDirectory returns the user's home directory
13+
// getHomeDirectory returns the user's home directory.
1414
// Tries HOME first, then falls back to USERPROFILE for Windows.
1515
func getHomeDirectory() string {
1616
homeDir := os.Getenv("HOME")

0 commit comments

Comments
 (0)