Set Ready For Review
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
// Copyright 2026 The Go Authors. All rights reserved.Patchset 1 is more or less https://go-review.git.corp.google.com/c/tools/+/794081/2/gopls/internal/cmd/normalize.go
but with some modification to accept cases like `gopls -otel=... serve`.
// TODO(adonovan): FlagSet.Parse should doI was trying to address this in CL 794760, but that's unsatisfactory.
The tricky part of using the complete subprocess-based testing to replace TestDispatch is, some subcommands like `gopls serve` or `gopls mcp` are
meant not to exit when successful. We can consider the gopls integration test framework like approach for serve/mcp, but that feels very heavy weight.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Directly print help for the resolved command.This is so much cleaner! Very nice.
Are we overlooking anything that the recursive tool.Run call did for us?
func TestHelp(t *testing.T) {
t.Parallel()
tree := writeTree(t, ``)
res := gopls(t, tree, "help", "remote")
res.checkExit(true)
res.checkStderr("interact with the gopls daemon")
}You can delete this; TestHelpTree does this and more.
If we move the tool package into cmd (in another CL), then all the Profile stuff in RunWithProfile can move right here. I think it will make things considerably simpler.
if i == len(args) {One alternative that we could evaluate is make dispatch not call parse at all, but merely shuffle the arguments into the normalized order (e.g. `gopls -listen=... -otel=...` -> `gopls -otel=... serve -listen=...`) so that the caller can then proceed to call appFlags.Parse exactly once and cmdFlags.Parse exactly once.
Given that you named this file normalize, I'm guessing you started out with this idea but hit a snag?
if strings.HasPrefix(arg, "-") && arg != "-" && arg != "--" {I don't think this is precise: you need to know which flags are boolean (see L143 et seq) to parse correctly, and you also need to know when to stop. Hence my ugly logic with two maps in https://go-review.git.corp.google.com/c/tools/+/794081/2/gopls/internal/cmd/normalize.go.
Otherwise both of these (admittedly hypothetical cases today) would trigger spurious errors about `-v` being after `serve`:
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |