diff options
Diffstat (limited to 'akonadish')
-rw-r--r-- | akonadish/main.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
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 @@ | |||
36 | * 3. called with commands: try to match to syntx | 36 | * 3. called with commands: try to match to syntx |
37 | */ | 37 | */ |
38 | 38 | ||
39 | void processCommandStream(QTextStream &stream) | ||
40 | { | ||
41 | QString line = stream.readLine(); | ||
42 | while (!line.isEmpty()) { | ||
43 | line = line.trimmed(); | ||
44 | |||
45 | if (!line.isEmpty() && !line.startsWith('#')) { | ||
46 | SyntaxTree::self()->run(SyntaxTree::tokenize(line)); | ||
47 | } | ||
48 | |||
49 | line = stream.readLine(); | ||
50 | } | ||
51 | } | ||
52 | |||
39 | int main(int argc, char *argv[]) | 53 | int main(int argc, char *argv[]) |
40 | { | 54 | { |
41 | const bool interactive = isatty(fileno(stdin)); | 55 | const bool interactive = isatty(fileno(stdin)); |
@@ -72,30 +86,11 @@ int main(int argc, char *argv[]) | |||
72 | return 1; | 86 | return 1; |
73 | } | 87 | } |
74 | 88 | ||
75 | QString line = f.readLine(); | 89 | QTextStream inputStream(&f); |
76 | while (!line.isEmpty()) { | 90 | processCommandStream(inputStream); |
77 | line = line.trimmed(); | ||
78 | |||
79 | if (!line.isEmpty() && !line.startsWith('#')) { | ||
80 | SyntaxTree::self()->run(SyntaxTree::tokenize(line)); | ||
81 | } | ||
82 | |||
83 | line = f.readLine(); | ||
84 | } | ||
85 | exit(0); | ||
86 | } else if (!interactive) { | 91 | } else if (!interactive) { |
87 | QTextStream inputStream(stdin); | 92 | QTextStream inputStream(stdin); |
88 | 93 | processCommandStream(inputStream); | |
89 | QString line = inputStream.readLine(); | ||
90 | while (!line.isEmpty()) { | ||
91 | line = line.trimmed(); | ||
92 | |||
93 | if (!line.isEmpty() && !line.startsWith('#')) { | ||
94 | SyntaxTree::self()->run(SyntaxTree::tokenize(line)); | ||
95 | } | ||
96 | |||
97 | line = inputStream.readLine(); | ||
98 | } | ||
99 | } else { | 94 | } else { |
100 | QStringList commands = app.arguments(); | 95 | QStringList commands = app.arguments(); |
101 | commands.removeFirst(); | 96 | commands.removeFirst(); |