From 8b397cec29460e2cb53b9be02b4e53da9cce60c9 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Thu, 24 Dec 2015 16:23:46 +0100 Subject: bye-bye header files the function-centric approach simply does not require them! --- akonadish/syntax_modules/akonadi_count.cpp | 24 +++++++-------- akonadish/syntax_modules/akonadi_count.h | 29 ------------------ akonadish/syntax_modules/akonadi_list.cpp | 24 +++++++-------- akonadish/syntax_modules/akonadi_list.h | 29 ------------------ akonadish/syntax_modules/akonadi_sync.cpp | 24 +++++++-------- akonadish/syntax_modules/akonadi_sync.h | 29 ------------------ akonadish/syntax_modules/core_syntax.cpp | 49 +++++++++++++++--------------- akonadish/syntax_modules/core_syntax.h | 33 -------------------- 8 files changed, 61 insertions(+), 180 deletions(-) delete mode 100644 akonadish/syntax_modules/akonadi_count.h delete mode 100644 akonadish/syntax_modules/akonadi_list.h delete mode 100644 akonadish/syntax_modules/akonadi_sync.h delete mode 100644 akonadish/syntax_modules/core_syntax.h (limited to 'akonadish/syntax_modules') diff --git a/akonadish/syntax_modules/akonadi_count.cpp b/akonadish/syntax_modules/akonadi_count.cpp index e54ac22..70aabc9 100644 --- a/akonadish/syntax_modules/akonadi_count.cpp +++ b/akonadish/syntax_modules/akonadi_count.cpp @@ -17,8 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "akonadi_count.h" - #include #include #include // tr() @@ -35,20 +33,12 @@ #include "common/definitions.h" #include "akonadish_utils.h" +#include "state.h" +#include "syntaxtree.h" namespace AkonadiCount { -REGISTER_SYNTAX(AkonadiCount) - -Syntax::List syntax() -{ - Syntax::List syntax; - syntax << Syntax("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count "), &AkonadiCount::count, Syntax::EventDriven); - - return syntax; -} - bool count(const QStringList &args, State &state) { auto resources = args; @@ -78,4 +68,14 @@ bool count(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax::List syntax; + syntax << Syntax("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count "), &AkonadiCount::count, Syntax::EventDriven); + + return syntax; +} + +REGISTER_SYNTAX(AkonadiCount) + } diff --git a/akonadish/syntax_modules/akonadi_count.h b/akonadish/syntax_modules/akonadi_count.h deleted file mode 100644 index c592c4c..0000000 --- a/akonadish/syntax_modules/akonadi_count.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2014 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include "syntaxtree.h" - -namespace AkonadiCount -{ - Syntax::List syntax(); - bool count(const QStringList &commands, State &state); -} - diff --git a/akonadish/syntax_modules/akonadi_list.cpp b/akonadish/syntax_modules/akonadi_list.cpp index 25ebbca..25ccabf 100644 --- a/akonadish/syntax_modules/akonadi_list.cpp +++ b/akonadish/syntax_modules/akonadi_list.cpp @@ -17,8 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "akonadi_list.h" - #include #include #include // tr() @@ -35,20 +33,12 @@ #include "common/definitions.h" #include "akonadish_utils.h" +#include "state.h" +#include "syntaxtree.h" namespace AkonadiList { -REGISTER_SYNTAX(AkonadiList) - -Syntax::List syntax() -{ - Syntax::List syntax; - syntax << Syntax("list", QObject::tr("List all resources, or the contents of one or more resources"), &AkonadiList::list, Syntax::EventDriven); - - return syntax; -} - bool list(const QStringList &args, State &state) { auto resources = args; @@ -111,4 +101,14 @@ bool list(const QStringList &args, State &state) return false; } +Syntax::List syntax() +{ + Syntax::List syntax; + syntax << Syntax("list", QObject::tr("List all resources, or the contents of one or more resources"), &AkonadiList::list, Syntax::EventDriven); + + return syntax; +} + +REGISTER_SYNTAX(AkonadiList) + } diff --git a/akonadish/syntax_modules/akonadi_list.h b/akonadish/syntax_modules/akonadi_list.h deleted file mode 100644 index 61effc5..0000000 --- a/akonadish/syntax_modules/akonadi_list.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2014 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include "syntaxtree.h" - -namespace AkonadiList -{ - Syntax::List syntax(); - bool list(const QStringList &commands, State &state); -} - diff --git a/akonadish/syntax_modules/akonadi_sync.cpp b/akonadish/syntax_modules/akonadi_sync.cpp index e9388d2..1cf097d 100644 --- a/akonadish/syntax_modules/akonadi_sync.cpp +++ b/akonadish/syntax_modules/akonadi_sync.cpp @@ -17,8 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "akonadi_sync.h" - #include #include // tr() #include @@ -33,20 +31,12 @@ #include "common/definitions.h" #include "akonadish_utils.h" +#include "state.h" +#include "syntaxtree.h" namespace AkonadiSync { -REGISTER_SYNTAX(AkonadiSync) - -Syntax::List syntax() -{ - Syntax::List syntax; - syntax << Syntax("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, Syntax::EventDriven ); - - return syntax; -} - bool sync(const QStringList &args, State &state) { Akonadi2::Query query; @@ -66,4 +56,14 @@ bool sync(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax::List syntax; + syntax << Syntax("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, Syntax::EventDriven ); + + return syntax; +} + +REGISTER_SYNTAX(AkonadiSync) + } diff --git a/akonadish/syntax_modules/akonadi_sync.h b/akonadish/syntax_modules/akonadi_sync.h deleted file mode 100644 index 62f7424..0000000 --- a/akonadish/syntax_modules/akonadi_sync.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2014 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include "syntaxtree.h" - -namespace AkonadiSync -{ - Syntax::List syntax(); - bool sync(const QStringList &commands, State &state); -} - diff --git a/akonadish/syntax_modules/core_syntax.cpp b/akonadish/syntax_modules/core_syntax.cpp index 8fb1448..a0cd4c6 100644 --- a/akonadish/syntax_modules/core_syntax.cpp +++ b/akonadish/syntax_modules/core_syntax.cpp @@ -17,37 +17,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "core_syntax.h" - #include #include // tr() #include #include -namespace CoreSyntax -{ - -REGISTER_SYNTAX(CoreSyntax) +#include "state.h" +#include "syntaxtree.h" -Syntax::List syntax() +namespace CoreSyntax { - Syntax::List syntax; - syntax << Syntax("exit", QObject::tr("Exits the application. Ctrl-d also works!"), &CoreSyntax::exit); - - Syntax help(QObject::tr("help"), QObject::tr("Print command information: help [command]"), &CoreSyntax::showHelp); - help.completer = &CoreSyntax::showHelpCompleter; - syntax << help; - - Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the session")); - set.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); - syntax << set; - - Syntax get(QObject::tr("get"), QObject::tr("Gets settings for the session")); - get.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::printDebugLevel); - syntax << get; - - return syntax; -} bool exit(const QStringList &, State &) { @@ -137,5 +116,27 @@ bool printDebugLevel(const QStringList &commands, State &state) return true; } +Syntax::List syntax() +{ + Syntax::List syntax; + syntax << Syntax("exit", QObject::tr("Exits the application. Ctrl-d also works!"), &CoreSyntax::exit); + + Syntax help(QObject::tr("help"), QObject::tr("Print command information: help [command]"), &CoreSyntax::showHelp); + help.completer = &CoreSyntax::showHelpCompleter; + syntax << help; + + Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the session")); + set.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); + syntax << set; + + Syntax get(QObject::tr("get"), QObject::tr("Gets settings for the session")); + get.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::printDebugLevel); + syntax << get; + + return syntax; +} + +REGISTER_SYNTAX(CoreSyntax) + } // namespace CoreSyntax diff --git a/akonadish/syntax_modules/core_syntax.h b/akonadish/syntax_modules/core_syntax.h deleted file mode 100644 index 89187e5..0000000 --- a/akonadish/syntax_modules/core_syntax.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2014 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include "syntaxtree.h" - -namespace CoreSyntax -{ - Syntax::List syntax(); - bool exit(const QStringList &commands, State &state); - bool showHelp(const QStringList &commands, State &state); - QStringList showHelpCompleter(const QStringList &commands, const QString &fragment); - bool setDebugLevel(const QStringList &commands, State &state); - bool printDebugLevel(const QStringList &commands, State &state); -} - -- cgit v1.2.3