[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-next/feature/new_cli] akonadi2_cli: piping now works
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2015-12-23 22:24:00
Message-ID: E1aBrpA-0001tF-Sw () scm ! kde ! org
[Download RAW message or body]

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 <QCoreApplication>
 #include <QDebug>
+#include <QTextStream>
 
 #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);
+    }
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic