From kde-commits Wed Dec 23 22:24:00 2015 From: Aaron Seigo Date: Wed, 23 Dec 2015 22:24:00 +0000 To: kde-commits Subject: [akonadi-next/feature/new_cli] akonadi2_cli: piping now works Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=145090945017880 Git commit 3e701d9387cf4ea5107893ef9d1018900aa73d74 by Aaron Seigo. Committed on 23/12/2015 at 22:19. Pushed by aseigo into branch 'feature/new_cli'. piping now works M +16 -4 akonadi2_cli/main.cpp http://commits.kde.org/akonadi-next/3e701d9387cf4ea5107893ef9d1018900aa73d74 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 =3D inputStream.readLine(); + if (input.isEmpty()) { + ::exit(0); + } = - QStringList commands =3D app.arguments(); - commands.removeFirst(); - return SyntaxTree::self()->run(commands); + const QStringList commands =3D SyntaxTree::tokenize(input); + SyntaxTree::self()->run(commands); + } + } else { + QStringList commands =3D app.arguments(); + commands.removeFirst(); + return SyntaxTree::self()->run(commands); + } }