diff options
author | Aaron Seigo <aseigo@kde.org> | 2016-01-10 12:09:30 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2016-01-10 12:09:30 +0100 |
commit | 378230eaa955d6915ad2a1b7792855595b598e05 (patch) | |
tree | faa63e17b5c48edefb7c831c99c2de303220dc89 | |
parent | cfc740798191673c9badb1a4543c5b5421054f27 (diff) | |
download | sink-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.cpp | 17 |
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 | ||
40 | int enterRepl() | 40 | int 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 | ||
58 | bool goInteractive(const QStringList &, State &) | ||
59 | { | ||
60 | enterRepl(); | ||
61 | return true; | ||
62 | } | ||
63 | |||
64 | Syntax::List goInteractiveSyntax() | ||
65 | { | ||
66 | Syntax interactive("go_interactive", QString(), &goInteractive); | ||
67 | return Syntax::List() << interactive; | ||
68 | } | ||
69 | |||
54 | void processCommandStream(QTextStream &stream) | 70 | void 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(); |