spf13/cobra — pull request #26 by ghodss (2014-09-25 23:24:08+00:00)
Title: Replace prefix matching with aliases

Implicit, automatic prefix matching can be a dangerous thing to automatically enable in CLI tools. Since it is generally considered best practice to maintain backwards compatibility with CLI tools, prefix matching means that the CLI tool author needs to be aware that every time they introduce a command, they in fact are introducing len(cmd) commands into the CLI which they would then be expected to maintain compatibility for, which is difficult and surprising. A better solution is to allow explicit aliases. This PR implements command aliases and removes prefix matching.

Note that I am not at all against the *option* of enabling prefix matching, but I could not find a way to expose that in a way that would be simple and consistent. IOW, the simplest way would be to add MatchPrefixes as a boolean on a command, but this creates a lot of questions: Does that apply to the command itself or its subcommands? Is it recursive? Does it apply to everything or just to that one command? Or just its subcommands? Given how confusing this gets I thought it best to drop prefix matching altogether.

I understand that this breaks backwards compatibility but I think this is important enough in order to prevent authors from inadvertently breaking their tools in the future.