summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-27 11:27:36 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-27 11:27:36 +0100
commite490c4798253a418d9fda17f40eff822f8d6ae36 (patch)
tree7351a5a5a9c4849f15ae90771c6c54aeb77fc3aa
parent96c7daa17f7db316419302c5bca7c3258c5a772b (diff)
parent43dfb87b20b6dc7cccf72cf9adb55608e184eb76 (diff)
downloadsink-e490c4798253a418d9fda17f40eff822f8d6ae36.tar.gz
sink-e490c4798253a418d9fda17f40eff822f8d6ae36.zip
Merge branch 'develop' of git://anongit.kde.org/akonadi-next into develop
-rw-r--r--akonadish/TODO2
-rw-r--r--akonadish/main.cpp21
2 files changed, 22 insertions, 1 deletions
diff --git a/akonadish/TODO b/akonadish/TODO
index 469dbf2..93c4ff1 100644
--- a/akonadish/TODO
+++ b/akonadish/TODO
@@ -3,6 +3,8 @@
3 * improve modify/remove/create to autocomplete resource names 3 * improve modify/remove/create to autocomplete resource names
4* provide a setting to turn on/off user interaction during commands (e.g. deletion confirmations) 4* provide a setting to turn on/off user interaction during commands (e.g. deletion confirmations)
5 * add a "ask the user a question" helper in State 5 * add a "ask the user a question" helper in State
6 * confirm deletions in remove
7* handle env vars and similar for scripting purposes
6* key/value syntax objects 8* key/value syntax objects
7* json objects! (set json on; ...) 9* json objects! (set json on; ...)
8* make the shell generic and have it load a plugin matching the name of argv[0] for syntax 10* make the shell generic and have it load a plugin matching the name of argv[0] for syntax
diff --git a/akonadish/main.cpp b/akonadish/main.cpp
index bd85fb4..45bd5ea 100644
--- a/akonadish/main.cpp
+++ b/akonadish/main.cpp
@@ -21,6 +21,7 @@
21 21
22#include <QCoreApplication> 22#include <QCoreApplication>
23#include <QDebug> 23#include <QDebug>
24#include <QFile>
24#include <QTextStream> 25#include <QTextStream>
25 26
26#include "syntaxtree.h" 27#include "syntaxtree.h"
@@ -42,7 +43,9 @@ int main(int argc, char *argv[])
42 //TODO: make a json command parse cause that would be awesomesauce 43 //TODO: make a json command parse cause that would be awesomesauce
43 const bool startJsonListener = !startRepl && 44 const bool startJsonListener = !startRepl &&
44 (argc == 2 && qstrcmp(argv[1], "-") == 0); 45 (argc == 2 && qstrcmp(argv[1], "-") == 0);
45 //qDebug() << "state at startup is" << interactive << startRepl << startJsonListener; 46 const bool fromScript = !startRepl && QFile::exists(argv[1]);
47
48 //qDebug() << "state at startup is" << interactive << startRepl << startJsonListener << fromScript;
46 49
47 QCoreApplication app(argc, argv); 50 QCoreApplication app(argc, argv);
48 app.setApplicationName(argv[0]); 51 app.setApplicationName(argv[0]);
@@ -62,6 +65,22 @@ int main(int argc, char *argv[])
62 65
63 State::setHasEventLoop(true); 66 State::setHasEventLoop(true);
64 return app.exec(); 67 return app.exec();
68 } else if (fromScript) {
69 QFile f(argv[1]);
70 if (!f.open(QIODevice::ReadOnly)) {
71 return 1;
72 }
73
74 QString line = f.readLine().trimmed();
75 while (!line.isEmpty()) {
76 if (line.isEmpty() || line.startsWith('#')) {
77 line = f.readLine().trimmed();
78 continue;
79 }
80 SyntaxTree::self()->run(SyntaxTree::tokenize(line));
81 line = f.readLine().trimmed();
82 }
83 exit(0);
65 } else if (!interactive) { 84 } else if (!interactive) {
66 QTextStream inputStream(stdin); 85 QTextStream inputStream(stdin);
67 while (true) { 86 while (true) {