Splits a line into a command and its arguments e.g. ":a b c d ." will be split into ":a" and " b c d ."
(line string)
| 226 | // Splits a line into a command and its arguments |
| 227 | // e.g. ":a b c d ." will be split into ":a" and " b c d ." |
| 228 | func splitLine(line string) (string, string) { |
| 229 | var command, arguments string |
| 230 | |
| 231 | line = strings.TrimSpace(line) |
| 232 | |
| 233 | // An empty line/a line consisting of whitespace contains neither command nor arguments |
| 234 | if len(line) > 0 { |
| 235 | command = strings.Fields(line)[0] |
| 236 | |
| 237 | // A line containing only a command has no arguments |
| 238 | if len(line) > len(command) { |
| 239 | arguments = line[len(command):] |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | return command, arguments |
| 244 | } |
| 245 | |
| 246 | func terminal(path string) (*liner.State, error) { |
| 247 | term := liner.NewLiner() |
no outgoing calls