enable stdin

This commit is contained in:
fuwa
2019-07-24 23:47:21 +00:00
parent 35710f9757
commit f1c3bd3a40
2 changed files with 19 additions and 3 deletions
+11 -2
View File
@@ -54,16 +54,25 @@ Stream<String> runBinary (String name, {Stream<String> input}) async* {
[
"--data-dir",
binDir.path,
"--non-interactive",
] + extraArgs + config.c.extraArgs;
log.info('args: ' + args.toString());
final outputProcess = await Process.start(newPath, args);
Future<void> printInput() async {
await for (final line in input) {
log.finest('process input: ' + line);
outputProcess.stdin.writeln(line);
outputProcess.stdin.flush();
}
}
if (input != null) {
outputProcess.stdin.addStream(input.transform(utf8.encoder));
printInput();
}
await for (final line in outputProcess.stdout.transform(utf8.decoder)) {
log.finest('process output: ' + line);
yield line;
}
+8 -1
View File
@@ -190,6 +190,8 @@ class SyncingState extends HookedState {
log.fine('syncing: loop exit');
// processInput.add('exit');
final _height = await rpc.height();
SyncedState _next = SyncedState(setState, getNotification, stdout, processInput, processOutput);
_next.height = _height;
@@ -211,6 +213,11 @@ class SyncedState extends HookedState {
SyncedState(f, s, this.stdout, this.processInput, this.processOutput) : super (f, s);
void appendInput(String line) {
stdout.addLast('> ' + line + '\n');
processInput.add(line);
}
Future<ReSyncingState> next() async {
log.fine("Synced next");
@@ -241,7 +248,7 @@ class SyncedState extends HookedState {
getTransactionPool = await rpc.getTransactionPoolSimple();
// processInput.add('help\n');
// appendInput('help');
// log.fine('getTransactionPool: $getTransactionPool');
syncState();