From ee3600d7f6a4e31e35dad5d0029d8b1e52d660ad Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 25 Dec 2015 11:05:55 +0100 Subject: error on unknown / malformed commands --- akonadish/syntaxtree.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'akonadish/syntaxtree.cpp') 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) bool success = false; m_timeElapsed.start(); Command command = match(commands); - if (command.first && command.first->lambda) { - success = command.first->lambda(command.second, m_state); - if (success && command.first->interactivity == Syntax::EventDriven) { - success = m_state.commandStarted(); + if (command.first) { + if (command.first->lambda) { + success = command.first->lambda(command.second, m_state); + if (success && command.first->interactivity == Syntax::EventDriven) { + success = m_state.commandStarted(); + } + } else if (command.first->children.isEmpty()) { + m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken"); + } else { + QStringList keywordList; + for (auto syntax: command.first->children) { + keywordList << syntax.keyword; + } + const QString keywords = keywordList.join(" " ); + m_state.printError(QObject::tr("Command requires additional arguments, one of: %1").arg(keywords)); } + } else { + m_state.printError(QObject::tr("Unknown command"), "st_unknown"); } if (m_state.commandTiming()) { -- cgit v1.2.3