From ad442fb49e5d4271a5f2276eb73d9d15b1e8755f Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 25 Dec 2015 10:31:24 +0100 Subject: support command timing output --- akonadish/syntaxtree.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'akonadish/syntaxtree.cpp') diff --git a/akonadish/syntaxtree.cpp b/akonadish/syntaxtree.cpp index 899fc61..dbbff01 100644 --- a/akonadish/syntaxtree.cpp +++ b/akonadish/syntaxtree.cpp @@ -62,16 +62,19 @@ Syntax::List SyntaxTree::syntax() const bool SyntaxTree::run(const QStringList &commands) { + bool success = false; + m_timeElapsed.start(); Command command = match(commands); if (command.first && command.first->lambda) { - bool rv = command.first->lambda(command.second, m_state); - if (rv && command.first->interactivity == Syntax::EventDriven) { - return m_state.commandStarted(); + success = command.first->lambda(command.second, m_state); + if (success && command.first->interactivity == Syntax::EventDriven) { + success = m_state.commandStarted(); } - - return rv; } + if (m_state.commandTiming()) { + m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed())); + } return false; } -- cgit v1.2.3