Git commit 75a2fd102611a01dba3ab7b9a26a2e05908a3a4c by Aaron Seigo. Committed on 26/12/2015 at 18:30. Pushed by aseigo into branch 'develop'. make it possible to write akonadish scripts.. help M +15 -0 akonadish/main.cpp http://commits.kde.org/akonadi-next/75a2fd102611a01dba3ab7b9a26a2e05908a3a4c diff --git a/akonadish/main.cpp b/akonadish/main.cpp index bd85fb4..6e7aa9e 100644 --- a/akonadish/main.cpp +++ b/akonadish/main.cpp @@ -21,6 +21,7 @@ = #include #include +#include #include = #include "syntaxtree.h" @@ -42,6 +43,8 @@ int main(int argc, char *argv[]) //TODO: make a json command parse cause that would be awesomesauce const bool startJsonListener =3D !startRepl && (argc =3D=3D 2 && qstrcmp(argv[1], "-")= =3D=3D 0); + const bool fromScript =3D !startRepl && QFile::exists(argv[1]); + //qDebug() << "state at startup is" << interactive << startRepl << sta= rtJsonListener; = QCoreApplication app(argc, argv); @@ -62,6 +65,18 @@ int main(int argc, char *argv[]) = State::setHasEventLoop(true); return app.exec(); + } else if (fromScript) { + QFile f(argv[1]); + if (!f.open(QIODevice::ReadOnly)) { = + return 1; + } + + QString line =3D f.readLine(); + while (!line.isEmpty()) { + SyntaxTree::self()->run(SyntaxTree::tokenize(line)); + line =3D f.readLine(); + } + exit(0); } else if (!interactive) { QTextStream inputStream(stdin); while (true) {