shortCommand shortens a command to a name we can use in a notification header.
(command string)
| 12 | // shortCommand shortens a command to a name we can use in a notification |
| 13 | // header. |
| 14 | func shortCommand(command string) string { |
| 15 | ret := command |
| 16 | parts := strings.Split(command, "\n") |
| 17 | for _, i := range parts { |
| 18 | i = strings.TrimLeft(i, " \t#") |
| 19 | i = strings.TrimRight(i, " \t\\") |
| 20 | if i != "" { |
| 21 | ret = i |
| 22 | break |
| 23 | } |
| 24 | } |
| 25 | return ret |
| 26 | } |
| 27 | |
| 28 | // niceHeader tries to produce a nicer process name. We condense whitespace to |
| 29 | // make commands split over multiple lines with indentation more legible, and |
no outgoing calls