cli_repl 0.2.1-nullsafety  cli_repl: ^0.2.1-nullsafety copied to clipboard
cli_repl: ^0.2.1-nullsafety copied to clipboard
A simple library for creating CLI REPLs
example/example.dart
/// Example REPL that looks for a semicolon to complete a statement and then
/// echoes all completed statements.
import 'package:cli_repl/cli_repl.dart';
main(args) async {
  var v = (str) => str.trim().isEmpty || str.trim().endsWith(';');
  var repl = new Repl(prompt: '>>> ', continuation: '... ', validator: v);
  await for (var x in repl.runAsync()) {
    if (x.trim().isEmpty) continue;
    print(x);
  }
}