From 3e701d9387cf4ea5107893ef9d1018900aa73d74 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Wed, 23 Dec 2015 23:19:15 +0100 Subject: piping now works --- akonadi2_cli/main.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'akonadi2_cli') diff --git a/akonadi2_cli/main.cpp b/akonadi2_cli/main.cpp index 91936c3..695fb82 100644 --- a/akonadi2_cli/main.cpp +++ b/akonadi2_cli/main.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "syntaxtree.h" // #include "jsonlistener.h" @@ -60,9 +61,20 @@ int main(int argc, char *argv[]) } return app.exec(); - } + } else if (!interactive) { + QTextStream inputStream(stdin); + while (true) { + const QString input = inputStream.readLine(); + if (input.isEmpty()) { + ::exit(0); + } - QStringList commands = app.arguments(); - commands.removeFirst(); - return SyntaxTree::self()->run(commands); + const QStringList commands = SyntaxTree::tokenize(input); + SyntaxTree::self()->run(commands); + } + } else { + QStringList commands = app.arguments(); + commands.removeFirst(); + return SyntaxTree::self()->run(commands); + } } -- cgit v1.2.3