step method

  1. @override
Future<bool> step(
  1. String method,
  2. String command,
  3. Object? params
)

returns true if command should be executed, false if should not be executed.

Implementation

@override
Future<bool> step(String method, String command, Object? params) async {
  if (!enabled) return true;
  print('$method $command(${json.encode(params)}):');
  await for (String command in _reader.onLine) {
    switch (command) {
      case 'continue':
      case 'c':
        return true;
      case 'skip':
      case 's':
        return false;
      case 'break':
      case 'b':
        throw Exception('process ended by user.');
      case 'help':
      case 'h':
        _printUsage();
        break;
      case 'disable':
      case 'd':
        enabled = false;
        return true;
      case 'quit':
      case 'q':
        return exit(-1);
      default:
        print('invalid command: `$command` enter `h` or `help` for help.');
    }
  }
  throw Exception('stdin has been closed');
}