[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-next/feature/new_cli] akonadish: error on unknown / malformed commands
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2015-12-25 10:26:12
Message-ID: E1aCPZc-0004HV-EW () scm ! kde ! org
[Download RAW message or body]

Git commit ee3600d7f6a4e31e35dad5d0029d8b1e52d660ad by Aaron Seigo.
Committed on 25/12/2015 at 10:05.
Pushed by aseigo into branch 'feature/new_cli'.

error on unknown / malformed commands

M  +17   -4    akonadish/syntaxtree.cpp

http://commits.kde.org/akonadi-next/ee3600d7f6a4e31e35dad5d0029d8b1e52d660ad

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()) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic