Skip to content

Migration: a name on the root is taken once

Before, a tool could pass NewCmdRoot a command with a built-in's name. Both were attached and both showed in the help. Which one ran depended on how cobra happened to sort the two, and adding an unrelated command could swap them.

Now the command already on the root keeps the name. Built-ins and the commands features contribute are attached first, so the tool's own command is skipped and the tool logs:

the tool's own "update" command is skipped: feature "update" already provides one; rename yours, or disable that feature

If you see that warning, choose one:

  • Keep your command: disable the feature, with gtb disable update in a generated project or props.Disable(props.UpdateCmd) by hand. version has no feature and can't be disabled.
  • Keep the built-in: rename your command.

The same goes for a name a plugin feature contributes, and for two of the tool's own commands with one name: the first is kept.

An alias that is another root command's name is dropped, and the command still runs under its own name:

the alias "update" of the "apply" command is dropped: feature "update" provides a command of that name

Nothing changes for a tool with no clash. A command registered on the root after NewCmdRoot returns isn't checked. Nor are help and completion, which cobra adds when the tool runs.