commandAliases is a templating function to return aliases for the command, formatted as the full command as they're called (contrary to the default Aliases function, which only returns the subcommand).
(cmd *cobra.Command)
| 243 | // formatted as the full command as they're called (contrary to the default |
| 244 | // Aliases function, which only returns the subcommand). |
| 245 | func commandAliases(cmd *cobra.Command) string { |
| 246 | if cmd.Annotations["aliases"] != "" { |
| 247 | return cmd.Annotations["aliases"] |
| 248 | } |
| 249 | var parentPath string |
| 250 | if cmd.HasParent() { |
| 251 | parentPath = cmd.Parent().CommandPath() + " " |
| 252 | } |
| 253 | var aliases strings.Builder |
| 254 | aliases.WriteString(cmd.CommandPath()) |
| 255 | for _, alias := range cmd.Aliases { |
| 256 | aliases.WriteString(", " + parentPath + alias) |
| 257 | } |
| 258 | return aliases.String() |
| 259 | } |
| 260 | |
| 261 | func topCommands(cmd *cobra.Command) []*cobra.Command { |
| 262 | cmds := []*cobra.Command{} |
searching dependent graphs…