MCPcopy Index your code
hub / github.com/gopherdata/gophernotes / evalSpecialCommands

Function evalSpecialCommands

kernel.go:699–723  ·  view source on GitHub ↗

find and execute special commands in code, remove them from returned string

(ir *interp.Interp, outerr OutErr, code string)

Source from the content-addressed store, hash-verified

697
698// find and execute special commands in code, remove them from returned string
699func evalSpecialCommands(ir *interp.Interp, outerr OutErr, code string) string {
700 lines := strings.Split(code, "\n")
701 stop := false
702 for i, line := range lines {
703 line = strings.TrimSpace(line)
704 if len(line) != 0 {
705 switch line[0] {
706 case '%':
707 evalSpecialCommand(ir, outerr, line)
708 lines[i] = ""
709 case '$':
710 evalShellCommand(ir, outerr, line)
711 lines[i] = ""
712 default:
713 // if a line is NOT a special command,
714 // stop processing special commands
715 stop = true
716 }
717 }
718 if stop {
719 break
720 }
721 }
722 return strings.Join(lines, "\n")
723}
724
725// execute special command. line must start with '%'
726func evalSpecialCommand(ir *interp.Interp, outerr OutErr, line string) {

Callers 1

doEvalFunction · 0.85

Calls 2

evalSpecialCommandFunction · 0.85
evalShellCommandFunction · 0.85

Tested by

no test coverage detected