Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: be more forgiving with matching names for help #51300

Open
robpike opened this issue Feb 21, 2022 · 3 comments
Open

cmd/go: be more forgiving with matching names for help #51300

robpike opened this issue Feb 21, 2022 · 3 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@robpike
Copy link
Contributor

robpike commented Feb 21, 2022

The go help output for topics is mostly good, but guessing how to spell the name of a particular topic can be difficult due to a combination of inconsistencies in the names matched, rigidity in the matching, and little assistance except asking for the full list. For example, is it singular (go help testflag) or plural (go help modules)? Is it hyphenated (go help module-get (not modules-get!)) or not (go help buildmode)?

The output for commands is less troubled, as it is quicker to access the list and the rules just match the commands, which are short and a little bit consistent already. But even here, I had to look at the list again today, as the command is called "work" but the feature is always called "workspaces".

I suggest the matching algorithm be relaxed. I don't have a particular preference about the mechanism, but it could be as simple as having multiple names for a given command or topic (work, workspace, workspaces), using a prefix-driven algorithm, or some edit distance thing. In practice I find the last form steps too far from the goal, so the one of first two approaches would be my choice, but really anything less rigid would be an improvement.

This sort of thing is a common courtesy honored by many programs in the world. The go command could strive to be more accommodating.

@kashav
Copy link
Contributor

kashav commented Feb 21, 2022

Perhaps some sort of "most similar command" output, like git?

$ git lol
git: 'lol' is not a git command. See 'git --help'.

The most similar command is
	log
$ git stat
git: 'stat' is not a git command. See 'git --help'.

The most similar commands are
	status
	stage
	stash

@robpike
Copy link
Contributor Author

robpike commented Feb 21, 2022

That's what I was referring to as the less preferred option, as it cast too wide a net. To go from 'stat' to 'stash', as in your example, is not helpful, and with git I often see much worse suggestions when I mistype something, It's actually pretty terrible. Real example:

% git foo
git: 'foo' is not a git command. See 'git --help'.

The most similar commands are
	gofmt
	log
% 

@rsc
Copy link
Contributor

rsc commented Feb 22, 2022

In the not-so-long term, the plan is to move the essays out of 'go help' entirely, so that you can 'go help ' and that's it.

In terms of git, right now go help is too much like 'git log --help' and not enough like 'git log -h'.

@bcmills bcmills added the GoCommand cmd/go label Feb 22, 2022
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 22, 2022
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants