MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / ExpandCommand

Function ExpandCommand

internal/scripting/util_func.go:198–225  ·  view source on GitHub ↗
(cmd string, limit ...int)

Source from the content-addressed store, hash-verified

196}
197
198func 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}

Callers 8

onCommandFunction · 0.85
onCommandFunction · 0.85
onCommandFunction · 0.85
onCommandFunction · 0.85
onCommandFunction · 0.85
onCommandFunction · 0.85
onCommandFunction · 0.85
onCommandFunction · 0.85

Calls 2

SplitButRespectQuotesFunction · 0.92
TryCommandAliasFunction · 0.92

Tested by

no test coverage detected