MCPcopy Index your code
hub / github.com/abiosoft/ishell / readMultiLinesFunc

Method readMultiLinesFunc

ishell.go:335–359  ·  view source on GitHub ↗
(f func(string) bool)

Source from the content-addressed store, hash-verified

333}
334
335func (s *Shell) readMultiLinesFunc(f func(string) bool) (string, error) {
336 var lines bytes.Buffer
337 currentLine := 0
338 var err error
339 for {
340 if currentLine == 1 {
341 // from second line, enable next line prompt.
342 s.reader.setMultiMode(true)
343 }
344 var line string
345 line, err = s.readLine()
346 fmt.Fprint(&lines, line)
347 if !f(line) || err != nil {
348 break
349 }
350 fmt.Fprintln(&lines)
351 currentLine++
352 }
353 if currentLine > 0 {
354 // if more than one line is read
355 // revert to standard prompt.
356 s.reader.setMultiMode(false)
357 }
358 return lines.String(), err
359}
360
361func (s *Shell) initCompleters() {
362 s.setCompleter(iCompleter{cmd: s.rootCmd, disabled: func() bool { return s.multiChoiceActive }})

Callers 2

readMethod · 0.95
ReadMultiLinesFuncMethod · 0.80

Calls 2

readLineMethod · 0.95
setMultiModeMethod · 0.80

Tested by

no test coverage detected