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

List:       kde-commits
Subject:    [akonadi-next/feature/akonadish_gointeractive] akonadish: factor out the common multiline input rout
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2016-01-10 11:15:48
Message-ID: E1aIDyO-0005fz-Dc () scm ! kde ! org
[Download RAW message or body]

Git commit ec380cc4ac09714c91a0b506563fac79c8b6b339 by Aaron Seigo.
Committed on 10/01/2016 at 10:55.
Pushed by aseigo into branch 'feature/akonadish_gointeractive'.

factor out the common multiline input routine

M  +17   -22   akonadish/main.cpp

http://commits.kde.org/akonadi-next/ec380cc4ac09714c91a0b506563fac79c8b6b339

diff --git a/akonadish/main.cpp b/akonadish/main.cpp
index f3cbcac..ba8be96 100644
--- a/akonadish/main.cpp
+++ b/akonadish/main.cpp
@@ -36,6 +36,20 @@
  *   3. called with commands: try to match to syntx
  */
 
+void processCommandStream(QTextStream &stream)
+{
+    QString line = stream.readLine();
+    while (!line.isEmpty()) {
+        line = line.trimmed();
+
+        if (!line.isEmpty() && !line.startsWith('#')) {
+            SyntaxTree::self()->run(SyntaxTree::tokenize(line));
+        }
+
+        line = stream.readLine();
+    }
+}
+
 int main(int argc, char *argv[])
 {
     const bool interactive = isatty(fileno(stdin));
@@ -72,30 +86,11 @@ int main(int argc, char *argv[])
             return 1;
         }
 
-        QString line = f.readLine();
-        while (!line.isEmpty()) {
-            line = line.trimmed();
-
-            if (!line.isEmpty() && !line.startsWith('#')) {
-                SyntaxTree::self()->run(SyntaxTree::tokenize(line));
-            }
-
-            line = f.readLine();
-        }
-        exit(0);
+        QTextStream inputStream(&f);
+        processCommandStream(inputStream);
     } else if (!interactive) {
         QTextStream inputStream(stdin);
-
-        QString line = inputStream.readLine();
-        while (!line.isEmpty()) {
-            line = line.trimmed();
-
-            if (!line.isEmpty() && !line.startsWith('#')) {
-                SyntaxTree::self()->run(SyntaxTree::tokenize(line));
-            }
-
-            line = inputStream.readLine();
-        }
+        processCommandStream(inputStream);
     } else {
         QStringList commands = app.arguments();
         commands.removeFirst();

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

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