MCPcopy
hub / github.com/x-motemen/gore / invokeCommand

Method invokeCommand

session.go:487–512  ·  view source on GitHub ↗
(in string)

Source from the content-addressed store, hash-verified

485}
486
487func (s *Session) invokeCommand(in string) (err error) {
488 in = strings.TrimLeftFunc(in, func(c rune) bool {
489 return c == ':' || unicode.IsSpace(c)
490 })
491 tokens := strings.Fields(in)
492 if len(tokens) == 0 {
493 return
494 }
495 cmd := tokens[0]
496 arg := strings.TrimSpace(strings.TrimPrefix(in, cmd))
497 for _, command := range commands {
498 if !command.name.matches(cmd) {
499 continue
500 }
501 err = command.action(s, arg)
502 if err != nil {
503 if err == ErrQuit {
504 return
505 }
506 err = fmt.Errorf("%s: %s", command.name, err)
507 }
508 s.updateCompleter()
509 return
510 }
511 return fmt.Errorf("command not found: %s", cmd)
512}
513
514// storeCode stores current state of code so that it can be restored
515func (s *Session) storeCode() {

Callers 1

EvalMethod · 0.95

Calls 2

updateCompleterMethod · 0.95
matchesMethod · 0.80

Tested by

no test coverage detected