@@ -128,6 +128,11 @@ func TestGo(t *testing.T) {
128128 {"tool trace" , "go tool trace trace.out" , "go tool trace <dotted-id>" },
129129 {"tool pprof path" , "go tool pprof ./cpu.prof" , "go tool pprof <path>" },
130130 {"tool dist list" , "go tool dist list" , "go tool dist list" },
131+ {"tool cover func fused" , "go tool cover -func=/tmp/cov.out" , "go tool cover -func=<path>" },
132+ {"tool cover html fused" , "go tool cover -html=/tmp/cov.out -o /tmp/cov.html" , "go tool cover -html=<path> -o <path>" },
133+ {"tool cover func separate" , "go tool cover -func /tmp/cov.out" , "go tool cover -func <path>" },
134+ {"tool cover func subshell" , "go tool cover -func $(get-file)" , "go tool cover -func $(get-file)" },
135+ {"tool cover unknown fused" , "go tool cover -cpuprofile=cpu.out" , "go tool cover -cpuprofile=cpu.out" },
131136
132137 // Shared build flags across subcommands
133138 {"build p flag" , "go build -p 4 ." , "go build -p N ." },
@@ -139,6 +144,106 @@ func TestGo(t *testing.T) {
139144 {"test stderr redirect" , "go test ./... 2>&1" , "go test <path> 2>&1" },
140145 {"vet stderr" , "go vet ./... 2>&1" , "go vet <path> 2>&1" },
141146
147+ // Fused flag forms (go test specific)
148+ {"test run=pattern fused" , "go test -run=TestFoo ./..." , "go test -run=<pattern> <path>" },
149+ {"test coverprofile=path fused" , "go test -coverprofile=cov.out ./..." , "go test -coverprofile=<path> <path>" },
150+ {"test coverpkg=val fused" , "go test -coverpkg=./pkg/... ./..." , "go test -coverpkg=<val> <path>" },
151+
152+ // Subshell in flag argument positions
153+ {"test run subshell" , "go test -run $(get-pattern) ./..." , "go test -run $(get-pattern) <path>" },
154+ {"test timeout subshell" , "go test -timeout $(calc-timeout) ./..." , "go test -timeout $(calc-timeout) <path>" },
155+ {"test coverprofile subshell" , "go test -coverprofile $(mktemp) ./..." , "go test -coverprofile $(mktemp) <path>" },
156+ {"test count subshell" , "go test -count $(nproc) ./..." , "go test -count $(nproc) <path>" },
157+ {"test coverpkg subshell" , "go test -coverpkg $(get-pkg) ./..." , "go test -coverpkg $(get-pkg) <path>" },
158+ {"build ldflags subshell" , "go build -ldflags $(gen-flags) ." , "go build -ldflags $(gen-flags) ." },
159+ {"build o subshell" , "go build -o $(get-path) ." , "go build -o $(get-path) ." },
160+
161+ // Trailing flag with no arg
162+ {"test trailing run" , "go test -run" , "go test -run" },
163+ {"test trailing count" , "go test -count" , "go test -count" },
164+
165+ // go run edge cases
166+ {"run subshell file" , "go run $(find-main)" , "go run $(find-main)" },
167+ {"run with build flags" , "go run -tags integration ./cmd/app arg1 arg2" , "go run -tags <val> <path> arg1 arg2" },
168+ {"run ldflags" , "go run -ldflags \" -X main.v=1\" main.go" , "go run -ldflags <val> <path>" },
169+ {"run p flag" , "go run -p 2 main.go" , "go run -p N <path>" },
170+ {"run subshell in flags" , "go run -tags $(get-tags) main.go" , "go run -tags $(get-tags) <path>" },
171+
172+ // go install edge cases
173+ {"install with tags" , "go install -tags netgo ./cmd/server" , "go install -tags <val> <path>" },
174+ {"install subshell" , "go install $(get-pkg)" , "go install $(get-pkg)" },
175+ {"install ldflags" , "go install -ldflags \" -s\" golang.org/x/tools/gopls@latest" , "go install -ldflags <val> golang.org/x/tools/gopls@latest" },
176+ {"install p flag" , "go install -p 4 ./cmd/app" , "go install -p N <path>" },
177+
178+ // go get edge cases
179+ {"get subshell" , "go get $(cat go.mod-dep)" , "go get $(cat go.mod-dep)" },
180+ {"get relative path" , "go get ../other-module" , "go get <path>" },
181+
182+ // go mod edge cases
183+ {"mod edit subshell" , "go mod edit -replace $(gen-replace)" , "go mod edit -replace $(gen-replace)" },
184+ {"mod subshell positional" , "go mod why $(get-dep)" , "go mod why $(get-dep)" },
185+ {"mod edit go flag" , "go mod edit -go 1.21" , "go mod edit -go <val>" },
186+ {"mod edit dropexclude" , "go mod edit -dropexclude github.com/old/dep@v1.0" , "go mod edit -dropexclude <val>" },
187+ {"mod edit trailing flag" , "go mod edit -require" , "go mod edit -require" },
188+
189+ // go doc edge cases
190+ {"doc subshell" , "go doc $(get-symbol)" , "go doc $(get-symbol)" },
191+
192+ // go env edge cases
193+ {"env subshell" , "go env $(get-var)" , "go env $(get-var)" },
194+ {"env multiple set" , "go env -w GOBIN=/usr/local/bin GOPROXY=direct" , "go env -w GOBIN=<val> GOPROXY=<val>" },
195+
196+ // go list edge cases
197+ {"list with tags" , "go list -tags integration ./..." , "go list -tags <val> <path>" },
198+ {"list subshell" , "go list $(get-pattern)" , "go list $(get-pattern)" },
199+ {"list f subshell" , "go list -f $(get-fmt) ./..." , "go list -f $(get-fmt) <path>" },
200+
201+ // go tool edge cases
202+ {"tool subshell" , "go tool $(get-tool)" , "go tool $(get-tool)" },
203+
204+ // go default handler edge cases
205+ {"vet subshell" , "go vet $(get-pkg)" , "go vet $(get-pkg)" },
206+ {"vet p flag" , "go vet -p 4 ./..." , "go vet -p N <path>" },
207+ {"fmt subshell" , "go fmt $(get-pkg)" , "go fmt $(get-pkg)" },
208+ {"generate tags" , "go generate -tags wireinject ./..." , "go generate -tags <val> <path>" },
209+ {"default subshell flag arg" , "go vet -tags $(get-tags) ./..." , "go vet -tags $(get-tags) <path>" },
210+ {"default trailing tags" , "go vet -tags" , "go vet -tags" },
211+
212+ // Unknown fused flag - classifyToken keeps it verbatim since it's a flag
213+ {"test unknown fused flag" , "go test -benchmem=true ./..." , "go test -benchmem=true <path>" },
214+
215+ // go test subshell in test-specific fused positions
216+ {"test fused timeout subshell" , "go test -timeout=30s ./..." , "go test -timeout=<duration> <path>" },
217+
218+ // go build subshell in build-specific flag positions
219+ {"build tags subshell" , "go build -tags $(get-tags) ." , "go build -tags $(get-tags) ." },
220+ {"build subshell positional" , "go build $(get-pkg)" , "go build $(get-pkg)" },
221+
222+ // go install build flag subshells
223+ {"install tags subshell" , "go install -tags $(get-tags) ./cmd/app" , "go install -tags $(get-tags) <path>" },
224+ {"install subshell positional" , "go install $(get-url)" , "go install $(get-url)" },
225+
226+ // go mod subshell in edit flag positions
227+ {"mod edit replace subshell" , "go mod edit -replace $(gen-replace)" , "go mod edit -replace $(gen-replace)" },
228+ {"mod edit flag subshell" , "go mod edit -go $(get-version)" , "go mod edit -go $(get-version)" },
229+ {"mod edit boolean flag" , "go mod edit -json" , "go mod edit -json" },
230+
231+ // go tool subshell and flag handling
232+ {"tool flag before name" , "go tool -n pprof" , "go tool -n pprof" },
233+ {"tool subshell after name" , "go tool pprof $(get-profile)" , "go tool pprof $(get-profile)" },
234+
235+ // go install boolean flag
236+ {"install verbose" , "go install -v golang.org/x/tools/gopls@latest" , "go install -v golang.org/x/tools/gopls@latest" },
237+ {"install parent path" , "go install ../other/cmd" , "go install <path>" },
238+
239+ // go mod more coverage
240+ {"mod edit boolean only" , "go mod edit -print" , "go mod edit -print" },
241+ {"mod why subshell" , "go mod why $(get-dep)" , "go mod why $(get-dep)" },
242+ {"mod edit go subshell" , "go mod edit -go $(get-version)" , "go mod edit -go $(get-version)" },
243+
244+ // go run boolean flag after positional
245+ {"run race file args" , "go run -race main.go --port 8080" , "go run -race <path> --port 8080" },
246+
142247 // Edge cases
143248 {"bare go" , "go" , "go" },
144249 {"version" , "go version" , "go version" },
0 commit comments