summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2016-01-10 12:09:30 +0100
committerAaron Seigo <aseigo@kde.org>2016-01-10 12:09:30 +0100
commit378230eaa955d6915ad2a1b7792855595b598e05 (patch)
treefaa63e17b5c48edefb7c831c99c2de303220dc89
parentcfc740798191673c9badb1a4543c5b5421054f27 (diff)
downloadsink-378230eaa955d6915ad2a1b7792855595b598e05.tar.gz
sink-378230eaa955d6915ad2a1b7792855595b598e05.zip
make it possible to enter itneractive mode from a script
use case -> you want to set the default log and debug levels away from the defaults and then go into interactive mode: set logging warning go_interactive
-rw-r--r--akonadish/main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/akonadish/main.cpp b/akonadish/main.cpp
index af85a94..4c00b9b 100644
--- a/akonadish/main.cpp
+++ b/akonadish/main.cpp
@@ -39,6 +39,10 @@
39 39
40int enterRepl() 40int enterRepl()
41{ 41{
42 if (State::hasEventLoop()) {
43 return 0;
44 }
45
42 Repl *repl = new Repl; 46 Repl *repl = new Repl;
43 QObject::connect(repl, &QStateMachine::finished, 47 QObject::connect(repl, &QStateMachine::finished,
44 repl, &QObject::deleteLater); 48 repl, &QObject::deleteLater);
@@ -51,8 +55,21 @@ int enterRepl()
51 return rv; 55 return rv;
52} 56}
53 57
58bool goInteractive(const QStringList &, State &)
59{
60 enterRepl();
61 return true;
62}
63
64Syntax::List goInteractiveSyntax()
65{
66 Syntax interactive("go_interactive", QString(), &goInteractive);
67 return Syntax::List() << interactive;
68}
69
54void processCommandStream(QTextStream &stream) 70void processCommandStream(QTextStream &stream)
55{ 71{
72 SyntaxTree::self()->registerSyntax(&goInteractiveSyntax);
56 QString line = stream.readLine(); 73 QString line = stream.readLine();
57 while (!line.isEmpty()) { 74 while (!line.isEmpty()) {
58 line = line.trimmed(); 75 line = line.trimmed();