| 302 | } |
| 303 | |
| 304 | func dedent(s string) string { |
| 305 | lines := strings.Split(s, "\n") |
| 306 | minIndent := -1 |
| 307 | |
| 308 | for _, l := range lines { |
| 309 | if len(l) == 0 { |
| 310 | continue |
| 311 | } |
| 312 | |
| 313 | indent := len(l) - len(strings.TrimLeft(l, " ")) |
| 314 | if minIndent == -1 || indent < minIndent { |
| 315 | minIndent = indent |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | if minIndent <= 0 { |
| 320 | return s |
| 321 | } |
| 322 | |
| 323 | var buf bytes.Buffer |
| 324 | for _, l := range lines { |
| 325 | fmt.Fprintln(&buf, strings.TrimPrefix(l, strings.Repeat(" ", minIndent))) |
| 326 | } |
| 327 | return strings.TrimSuffix(buf.String(), "\n") |
| 328 | } |
| 329 | |
| 330 | func BuildAliasList(cmd *cobra.Command, aliases []string) []string { |
| 331 | if !cmd.HasParent() { |