diff options
Diffstat (limited to 'akonadish/main.cpp')
-rw-r--r-- | akonadish/main.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/akonadish/main.cpp b/akonadish/main.cpp index 45bd5ea..f3cbcac 100644 --- a/akonadish/main.cpp +++ b/akonadish/main.cpp | |||
@@ -48,7 +48,8 @@ int main(int argc, char *argv[]) | |||
48 | //qDebug() << "state at startup is" << interactive << startRepl << startJsonListener << fromScript; | 48 | //qDebug() << "state at startup is" << interactive << startRepl << startJsonListener << fromScript; |
49 | 49 | ||
50 | QCoreApplication app(argc, argv); | 50 | QCoreApplication app(argc, argv); |
51 | app.setApplicationName(argv[0]); | 51 | app.setApplicationName(fromScript ? "interactive-app-shell" : argv[0]); |
52 | //app.setApplicationName(argv[0]); | ||
52 | 53 | ||
53 | if (startRepl || startJsonListener) { | 54 | if (startRepl || startJsonListener) { |
54 | if (startRepl) { | 55 | if (startRepl) { |
@@ -71,26 +72,29 @@ int main(int argc, char *argv[]) | |||
71 | return 1; | 72 | return 1; |
72 | } | 73 | } |
73 | 74 | ||
74 | QString line = f.readLine().trimmed(); | 75 | QString line = f.readLine(); |
75 | while (!line.isEmpty()) { | 76 | while (!line.isEmpty()) { |
76 | if (line.isEmpty() || line.startsWith('#')) { | 77 | line = line.trimmed(); |
77 | line = f.readLine().trimmed(); | 78 | |
78 | continue; | 79 | if (!line.isEmpty() && !line.startsWith('#')) { |
80 | SyntaxTree::self()->run(SyntaxTree::tokenize(line)); | ||
79 | } | 81 | } |
80 | SyntaxTree::self()->run(SyntaxTree::tokenize(line)); | 82 | |
81 | line = f.readLine().trimmed(); | 83 | line = f.readLine(); |
82 | } | 84 | } |
83 | exit(0); | 85 | exit(0); |
84 | } else if (!interactive) { | 86 | } else if (!interactive) { |
85 | QTextStream inputStream(stdin); | 87 | QTextStream inputStream(stdin); |
86 | while (true) { | 88 | |
87 | const QString input = inputStream.readLine(); | 89 | QString line = inputStream.readLine(); |
88 | if (input.isEmpty()) { | 90 | while (!line.isEmpty()) { |
89 | ::exit(0); | 91 | line = line.trimmed(); |
92 | |||
93 | if (!line.isEmpty() && !line.startsWith('#')) { | ||
94 | SyntaxTree::self()->run(SyntaxTree::tokenize(line)); | ||
90 | } | 95 | } |
91 | 96 | ||
92 | const QStringList commands = SyntaxTree::tokenize(input); | 97 | line = inputStream.readLine(); |
93 | SyntaxTree::self()->run(commands); | ||
94 | } | 98 | } |
95 | } else { | 99 | } else { |
96 | QStringList commands = app.arguments(); | 100 | QStringList commands = app.arguments(); |