| 196 | } |
| 197 | |
| 198 | func ExpandCommand(cmd string, limit ...int) string { |
| 199 | |
| 200 | parts := util.SplitButRespectQuotes(cmd) |
| 201 | |
| 202 | expansionsLeft := -1 |
| 203 | if len(limit) > 0 { |
| 204 | expansionsLeft = limit[0] |
| 205 | if expansionsLeft < -1 { |
| 206 | expansionsLeft = -1 |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | result := "" |
| 211 | for _, abbr := range parts { |
| 212 | if expansionsLeft != 0 { |
| 213 | alias := keywords.TryCommandAlias(abbr) |
| 214 | result += alias |
| 215 | expansionsLeft-- |
| 216 | } else { |
| 217 | result += abbr |
| 218 | } |
| 219 | result += " " |
| 220 | } |
| 221 | |
| 222 | result = strings.Trim(result, " ") |
| 223 | |
| 224 | return result |
| 225 | } |