| 287 | } |
| 288 | |
| 289 | func dedent(s string) string { |
| 290 | lines := strings.Split(s, "\n") |
| 291 | minIndent := -1 |
| 292 | |
| 293 | for _, l := range lines { |
| 294 | if len(l) == 0 { |
| 295 | continue |
| 296 | } |
| 297 | |
| 298 | indent := len(l) - len(strings.TrimLeft(l, " ")) |
| 299 | if minIndent == -1 || indent < minIndent { |
| 300 | minIndent = indent |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | if minIndent <= 0 { |
| 305 | return s |
| 306 | } |
| 307 | |
| 308 | var buf bytes.Buffer |
| 309 | for _, l := range lines { |
| 310 | fmt.Fprintln(&buf, strings.TrimPrefix(l, strings.Repeat(" ", minIndent))) |
| 311 | } |
| 312 | return strings.TrimSuffix(buf.String(), "\n") |
| 313 | } |
| 314 | |
| 315 | func BuildAliasList(cmd *cobra.Command, aliases []string) []string { |
| 316 | if !cmd.HasParent() { |