(f func(string) bool)
| 333 | } |
| 334 | |
| 335 | func (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 | |
| 361 | func (s *Shell) initCompleters() { |
| 362 | s.setCompleter(iCompleter{cmd: s.rootCmd, disabled: func() bool { return s.multiChoiceActive }}) |
no test coverage detected