[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [akonadi-next/feature/new_cli] akonadi2_cli/syntax_modules: set/get syntax, currently just for debug
From: Aaron Seigo <aseigo () kde ! org>
Date: 2015-12-23 16:08:05
Message-ID: E1aBlxN-0007dS-A7 () scm ! kde ! org
[Download RAW message or body]
Git commit e995699ad88e6c6f1980d11c45a544c79993ccb5 by Aaron Seigo.
Committed on 23/12/2015 at 16:02.
Pushed by aseigo into branch 'feature/new_cli'.
set/get syntax, currently just for debug level
M +35 -0 akonadi2_cli/syntax_modules/core_syntax.cpp
M +3 -1 akonadi2_cli/syntax_modules/core_syntax.h
http://commits.kde.org/akonadi-next/e995699ad88e6c6f1980d11c45a544c79993ccb5
diff --git a/akonadi2_cli/syntax_modules/core_syntax.cpp \
b/akonadi2_cli/syntax_modules/core_syntax.cpp index f71c1d6..f9cd622 100644
--- a/akonadi2_cli/syntax_modules/core_syntax.cpp
+++ b/akonadi2_cli/syntax_modules/core_syntax.cpp
@@ -19,6 +19,7 @@
#include "core_syntax.h"
+#include <QDebug>
#include <QObject> // tr()
#include <QSet>
#include <QTextStream>
@@ -31,6 +32,15 @@ SyntaxTree::SyntaxList syntax()
SyntaxTree::SyntaxList syntax;
syntax << SyntaxTree::Syntax("exit", QObject::tr("Exits the application. Ctrl-d \
also works!"), &CoreSyntax::exit);
syntax << SyntaxTree::Syntax(QObject::tr("help"), QObject::tr("Print command \
information: help [command]"), &CoreSyntax::showHelp); +
+ SyntaxTree::Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the \
session")); + set.children << SyntaxTree::Syntax(QObject::tr("debug"), \
QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); + \
syntax << set; +
+ SyntaxTree::Syntax get(QObject::tr("get"), QObject::tr("Gets settings for the \
session")); + get.children << SyntaxTree::Syntax(QObject::tr("debug"), \
QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::printDebugLevel); + \
syntax << get; +
return syntax;
}
@@ -82,5 +92,30 @@ bool showHelp(const QStringList &commands, State &state)
return true;
}
+bool setDebugLevel(const QStringList &commands, State &state)
+{
+ if (commands.count() != 1) {
+ state.printError(QObject::tr("Wrong number of arguments; expected 1 got \
%1").arg(commands.count())); + return false;
+ }
+
+ bool ok = false;
+ int level = commands[0].toUInt(&ok);
+
+ if (!ok) {
+ state.printError(QObject::tr("Expected a number between 0 and 6, got \
%1").arg(commands[0])); + return false;
+ }
+
+ state.setDebugLevel(level);
+ return true;
+}
+
+bool printDebugLevel(const QStringList &commands, State &state)
+{
+ state.printLine(QString::number(state.debugLevel()));
+ return true;
+}
+
} // namespace CoreSyntax
diff --git a/akonadi2_cli/syntax_modules/core_syntax.h \
b/akonadi2_cli/syntax_modules/core_syntax.h index 0db6661..4afd69d 100644
--- a/akonadi2_cli/syntax_modules/core_syntax.h
+++ b/akonadi2_cli/syntax_modules/core_syntax.h
@@ -25,6 +25,8 @@ namespace CoreSyntax
{
SyntaxTree::SyntaxList syntax();
bool exit(const QStringList &commands, State &state);
- bool showHelp(const QStringList &commands, State &);
+ bool showHelp(const QStringList &commands, State &state);
+ bool setDebugLevel(const QStringList &commands, State &state);
+ bool printDebugLevel(const QStringList &commands, State &state);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic