start method

Future<int> start()

Runs the shell until exit, Ctrl+D or the end of the input, and returns the exit code.

Implementation

Future<int> start() async {
  _editor = LiveLineEditor(
    input: _input,
    output: _output,
    terminal: terminal,
    history: _loadHistory(),
    historyLimit: _historyLimit,
    complete: _complete,
  );
  _interruptSubscription = _interrupts?.listen((_) {
    final void Function()? onInterrupt = _onInterrupt;
    if (onInterrupt != null) {
      onInterrupt();
    } else if (_editor.isReading) {
      _editor.cancelLine();
    }
  });

  try {
    return terminal.hasTerminal ? await _interactive() : await _script();
  } finally {
    await _interruptSubscription?.cancel();
    await session.close();
    await _editor.close();
  }
}