Skip to content

Commit 45c2fc9

Browse files
Copilotkeac
andcommitted
Improve code comments and help text clarity
- Add detailed comment explaining IsBoolFlag behavior - Update help text with specific usage examples - Address code review feedback Co-authored-by: keac <[email protected]>
1 parent 60ae379 commit 45c2fc9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

common/flag.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ func (m *mcpFlag) String() string {
1818
}
1919

2020
func (m *mcpFlag) Set(s string) error {
21-
// When IsBoolFlag returns true and flag is used without value,
22-
// Go sets it to "true". We treat "true" as "use config default"
21+
// When IsBoolFlag returns true and the flag is used without a value (e.g., --mcp alone),
22+
// Go's flag parser calls Set with "true" as the value.
23+
// We treat this special case as "use config default" by setting value to empty string.
24+
// For any other value (e.g., --mcp=:8080), we use that value directly.
2325
if s == "true" {
2426
m.value = "" // Empty means use config default
2527
} else {
@@ -84,7 +86,7 @@ func Flag(Info *ENOptions) {
8486

8587
// MCP flag with optional value support
8688
mcpFlagVar := &mcpFlag{}
87-
flag.Var(mcpFlagVar, "mcp", "MCP模式运行,可指定监听地址,如 :8080 http://localhost:8080,不指定则使用配置文件默认值")
89+
flag.Var(mcpFlagVar, "mcp", "MCP模式运行。用法: --mcp (使用配置文件默认值), --mcp=:8080 (自定义端口), --mcp=http://localhost:8080 (完整地址)")
8890

8991
flag.BoolVar(&Info.ISKeyPid, "is-pid", false, "批量查询文件是否为公司PID")
9092
flag.IntVar(&Info.DelayTime, "delay", 0, "每个请求延迟(S)-1为随机延迟1-5S")

0 commit comments

Comments
 (0)