[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [akonadi-next/develop] akonadish: make it possible to write akonadish scripts..
From: Aaron Seigo <aseigo () kde ! org>
Date: 2015-12-26 18:35:31
Message-ID: E1aCtgh-0006Il-1s () scm ! kde ! org
[Download RAW message or body]
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 <QCoreApplication>
#include <QDebug>
+#include <QFile>
#include <QTextStream>
#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 = !startRepl &&
(argc == 2 && qstrcmp(argv[1], "-") == 0);
+ const bool fromScript = !startRepl && QFile::exists(argv[1]);
+
//qDebug() << "state at startup is" << interactive << startRepl << startJsonListener;
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 = f.readLine();
+ while (!line.isEmpty()) {
+ SyntaxTree::self()->run(SyntaxTree::tokenize(line));
+ line = f.readLine();
+ }
+ exit(0);
} else if (!interactive) {
QTextStream inputStream(stdin);
while (true) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic