cli_repl
CLI REPL을 생성하기 위한 간단한 라이브러리
Dart에서 간단한 REPL을 만들기 위한 라이브러리
^2.5.0^0.6.3^0.9.0-nullsafety.0^2.0.0^1.16.5^2.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A simple library for creating CLI REPLs in Dart.
Example Usage:
/// Echoes all entered lines
for (var line in new Repl().run()) {
print(line);
}
By passing a validator to the Repl constructor, you can tell the REPL
whether some entered text is a complete statement or not. The REPL calls this
whenever a newline is entered to determine whether to yield a complete statement
or continue it on a new line. The default validator returns true for all text.
By default, the REPL gives no prompt to the user when asking for a statement.
You can change this by passing a prompt to the Repl constructor. By default,
statement continuations on a new line will start with whitespace equal to the
length of the prompt. You can override this by passing in continuation.
See example/example.dart for a demonstration of statement
validation and custom prompts.
A history of entered lines is stored. History entries are modified when edited.
By default, a maximum of 50 entries are stored. You can change this by passing
maxHistory into the Repl constructor.
Left/Ctrl-B: Move left one characterRight/Ctrl-F: Move right one characterHome/Ctrl-A: Move to start of lineEnd/Ctrl-E: Move to end of lineCtrl-L: Clear the screenCtrl-D: If there is text, delete the character under the cursor. If there is
no text, exit.Ctrl-F: Moves forward one characterCtrl-B: Moves backward one characterCtrl-U: Kill (cut) to start of lineCtrl-K: Kill (cut) to end of lineCtrl-Y: Yank (paste) previously killed text, inserting at cursorUp/Down: Navigate within historyIf running without a terminal, the input will be printed along with the prompts, allowing you to test REPLs made with this library by comparing stdout to the expected log input and output together.
See test/repl_test.dart for an example of this.
If you compile this to JS with Dart 2, you can run it on Node.
There are a couple of behavior differences:
Repl.runAsync() works. Calling Repl.run() will throw an error.