summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2015-12-25 11:05:55 +0100
committerAaron Seigo <aseigo@kde.org>2015-12-25 11:05:55 +0100
commitee3600d7f6a4e31e35dad5d0029d8b1e52d660ad (patch)
treef1827342400fadb6814d46737e50918a9538a038
parent540864148b9bccc4b00bb3ba504190d608489413 (diff)
downloadsink-ee3600d7f6a4e31e35dad5d0029d8b1e52d660ad.tar.gz
sink-ee3600d7f6a4e31e35dad5d0029d8b1e52d660ad.zip
error on unknown / malformed commands
-rw-r--r--akonadish/syntaxtree.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/akonadish/syntaxtree.cpp b/akonadish/syntaxtree.cpp
index dbbff01..4188e5f 100644
--- a/akonadish/syntaxtree.cpp
+++ b/akonadish/syntaxtree.cpp
@@ -65,11 +65,24 @@ bool SyntaxTree::run(const QStringList &commands)
65 bool success = false; 65 bool success = false;
66 m_timeElapsed.start(); 66 m_timeElapsed.start();
67 Command command = match(commands); 67 Command command = match(commands);
68 if (command.first && command.first->lambda) { 68 if (command.first) {
69 success = command.first->lambda(command.second, m_state); 69 if (command.first->lambda) {
70 if (success && command.first->interactivity == Syntax::EventDriven) { 70 success = command.first->lambda(command.second, m_state);
71 success = m_state.commandStarted(); 71 if (success && command.first->interactivity == Syntax::EventDriven) {
72 success = m_state.commandStarted();
73 }
74 } else if (command.first->children.isEmpty()) {
75 m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken");
76 } else {
77 QStringList keywordList;
78 for (auto syntax: command.first->children) {
79 keywordList << syntax.keyword;
80 }
81 const QString keywords = keywordList.join(" " );
82 m_state.printError(QObject::tr("Command requires additional arguments, one of: %1").arg(keywords));
72 } 83 }
84 } else {
85 m_state.printError(QObject::tr("Unknown command"), "st_unknown");
73 } 86 }
74 87
75 if (m_state.commandTiming()) { 88 if (m_state.commandTiming()) {