jathak / cli_repl Goto Github PK
View Code? Open in Web Editor NEWA library for creating a simple REPL in Dart
License: BSD 3-Clause "New" or "Revised" License
A library for creating a simple REPL in Dart
License: BSD 3-Clause "New" or "Revised" License
Hi! Thanks for writing this, it's just what I needed!
There's just one issue I found...
Running this code:
await for (var line in repl.runAsync()) {
print("you typed $line");
break;
}
print("Bye");
When I type something, I would expect it to exit immediatelly after I hit Enter, but it doesn't, it prints the prompt again, then the next time I hit Enter it finally exits.
Would be nice if it could break first time.
Thanks!
Take this sample program:
import 'package:cli_repl/cli_repl.dart';
void main() async {
final repl = Repl(prompt: '> ');
await for (final answer in repl.runAsync()) {
if (answer == 'exit') break;
await Future(() => print("You said '$answer'"));
}
print("done");
await repl.exit();
}
When running this program, the You said x
message is always printed after the prompt. This makes writing REPLs that evaluate commands async impossible even when the for-loop body await
s, as in this example.
The expected behaviour is to wait for the body to complete before printing the prompt.
It works on Linux but since keyboard code is platform dependent, some keys like 'backspace' uses different code on Windows. Arrow key not working because stdin
on Windows does not work properly.
Just want others to know this limitation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.