diff options
author | Aaron Seigo <aseigo@kde.org> | 2015-12-24 16:23:46 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2015-12-24 16:23:46 +0100 |
commit | 8b397cec29460e2cb53b9be02b4e53da9cce60c9 (patch) | |
tree | 430191293848e5a8051a99a00634ea685c101d53 /akonadish/syntax_modules | |
parent | b352f61f136f21854b3da5b76d49fe45cbb2d3fd (diff) | |
download | sink-8b397cec29460e2cb53b9be02b4e53da9cce60c9.tar.gz sink-8b397cec29460e2cb53b9be02b4e53da9cce60c9.zip |
bye-bye header files
the function-centric approach simply does not require them!
Diffstat (limited to 'akonadish/syntax_modules')
-rw-r--r-- | akonadish/syntax_modules/akonadi_count.cpp | 24 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_count.h | 29 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_list.cpp | 24 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_list.h | 29 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_sync.cpp | 24 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_sync.h | 29 | ||||
-rw-r--r-- | akonadish/syntax_modules/core_syntax.cpp | 49 | ||||
-rw-r--r-- | akonadish/syntax_modules/core_syntax.h | 33 |
8 files changed, 61 insertions, 180 deletions
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 @@ | |||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "akonadi_count.h" | ||
21 | |||
22 | #include <QCoreApplication> | 20 | #include <QCoreApplication> |
23 | #include <QDebug> | 21 | #include <QDebug> |
24 | #include <QObject> // tr() | 22 | #include <QObject> // tr() |
@@ -35,20 +33,12 @@ | |||
35 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
36 | 34 | ||
37 | #include "akonadish_utils.h" | 35 | #include "akonadish_utils.h" |
36 | #include "state.h" | ||
37 | #include "syntaxtree.h" | ||
38 | 38 | ||
39 | namespace AkonadiCount | 39 | namespace AkonadiCount |
40 | { | 40 | { |
41 | 41 | ||
42 | REGISTER_SYNTAX(AkonadiCount) | ||
43 | |||
44 | Syntax::List syntax() | ||
45 | { | ||
46 | Syntax::List syntax; | ||
47 | syntax << Syntax("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count <type> <resource>"), &AkonadiCount::count, Syntax::EventDriven); | ||
48 | |||
49 | return syntax; | ||
50 | } | ||
51 | |||
52 | bool count(const QStringList &args, State &state) | 42 | bool count(const QStringList &args, State &state) |
53 | { | 43 | { |
54 | auto resources = args; | 44 | auto resources = args; |
@@ -78,4 +68,14 @@ bool count(const QStringList &args, State &state) | |||
78 | return true; | 68 | return true; |
79 | } | 69 | } |
80 | 70 | ||
71 | Syntax::List syntax() | ||
72 | { | ||
73 | Syntax::List syntax; | ||
74 | syntax << Syntax("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count <type> <resource>"), &AkonadiCount::count, Syntax::EventDriven); | ||
75 | |||
76 | return syntax; | ||
77 | } | ||
78 | |||
79 | REGISTER_SYNTAX(AkonadiCount) | ||
80 | |||
81 | } | 81 | } |
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include "syntaxtree.h" | ||
23 | |||
24 | namespace AkonadiCount | ||
25 | { | ||
26 | Syntax::List syntax(); | ||
27 | bool count(const QStringList &commands, State &state); | ||
28 | } | ||
29 | |||
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 @@ | |||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "akonadi_list.h" | ||
21 | |||
22 | #include <QCoreApplication> | 20 | #include <QCoreApplication> |
23 | #include <QDebug> | 21 | #include <QDebug> |
24 | #include <QObject> // tr() | 22 | #include <QObject> // tr() |
@@ -35,20 +33,12 @@ | |||
35 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
36 | 34 | ||
37 | #include "akonadish_utils.h" | 35 | #include "akonadish_utils.h" |
36 | #include "state.h" | ||
37 | #include "syntaxtree.h" | ||
38 | 38 | ||
39 | namespace AkonadiList | 39 | namespace AkonadiList |
40 | { | 40 | { |
41 | 41 | ||
42 | REGISTER_SYNTAX(AkonadiList) | ||
43 | |||
44 | Syntax::List syntax() | ||
45 | { | ||
46 | Syntax::List syntax; | ||
47 | syntax << Syntax("list", QObject::tr("List all resources, or the contents of one or more resources"), &AkonadiList::list, Syntax::EventDriven); | ||
48 | |||
49 | return syntax; | ||
50 | } | ||
51 | |||
52 | bool list(const QStringList &args, State &state) | 42 | bool list(const QStringList &args, State &state) |
53 | { | 43 | { |
54 | auto resources = args; | 44 | auto resources = args; |
@@ -111,4 +101,14 @@ bool list(const QStringList &args, State &state) | |||
111 | return false; | 101 | return false; |
112 | } | 102 | } |
113 | 103 | ||
104 | Syntax::List syntax() | ||
105 | { | ||
106 | Syntax::List syntax; | ||
107 | syntax << Syntax("list", QObject::tr("List all resources, or the contents of one or more resources"), &AkonadiList::list, Syntax::EventDriven); | ||
108 | |||
109 | return syntax; | ||
110 | } | ||
111 | |||
112 | REGISTER_SYNTAX(AkonadiList) | ||
113 | |||
114 | } | 114 | } |
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include "syntaxtree.h" | ||
23 | |||
24 | namespace AkonadiList | ||
25 | { | ||
26 | Syntax::List syntax(); | ||
27 | bool list(const QStringList &commands, State &state); | ||
28 | } | ||
29 | |||
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 @@ | |||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "akonadi_sync.h" | ||
21 | |||
22 | #include <QDebug> | 20 | #include <QDebug> |
23 | #include <QObject> // tr() | 21 | #include <QObject> // tr() |
24 | #include <QTimer> | 22 | #include <QTimer> |
@@ -33,20 +31,12 @@ | |||
33 | #include "common/definitions.h" | 31 | #include "common/definitions.h" |
34 | 32 | ||
35 | #include "akonadish_utils.h" | 33 | #include "akonadish_utils.h" |
34 | #include "state.h" | ||
35 | #include "syntaxtree.h" | ||
36 | 36 | ||
37 | namespace AkonadiSync | 37 | namespace AkonadiSync |
38 | { | 38 | { |
39 | 39 | ||
40 | REGISTER_SYNTAX(AkonadiSync) | ||
41 | |||
42 | Syntax::List syntax() | ||
43 | { | ||
44 | Syntax::List syntax; | ||
45 | syntax << Syntax("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, Syntax::EventDriven ); | ||
46 | |||
47 | return syntax; | ||
48 | } | ||
49 | |||
50 | bool sync(const QStringList &args, State &state) | 40 | bool sync(const QStringList &args, State &state) |
51 | { | 41 | { |
52 | Akonadi2::Query query; | 42 | Akonadi2::Query query; |
@@ -66,4 +56,14 @@ bool sync(const QStringList &args, State &state) | |||
66 | return true; | 56 | return true; |
67 | } | 57 | } |
68 | 58 | ||
59 | Syntax::List syntax() | ||
60 | { | ||
61 | Syntax::List syntax; | ||
62 | syntax << Syntax("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, Syntax::EventDriven ); | ||
63 | |||
64 | return syntax; | ||
65 | } | ||
66 | |||
67 | REGISTER_SYNTAX(AkonadiSync) | ||
68 | |||
69 | } | 69 | } |
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include "syntaxtree.h" | ||
23 | |||
24 | namespace AkonadiSync | ||
25 | { | ||
26 | Syntax::List syntax(); | ||
27 | bool sync(const QStringList &commands, State &state); | ||
28 | } | ||
29 | |||
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 @@ | |||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "core_syntax.h" | ||
21 | |||
22 | #include <QDebug> | 20 | #include <QDebug> |
23 | #include <QObject> // tr() | 21 | #include <QObject> // tr() |
24 | #include <QSet> | 22 | #include <QSet> |
25 | #include <QTextStream> | 23 | #include <QTextStream> |
26 | 24 | ||
27 | namespace CoreSyntax | 25 | #include "state.h" |
28 | { | 26 | #include "syntaxtree.h" |
29 | |||
30 | REGISTER_SYNTAX(CoreSyntax) | ||
31 | 27 | ||
32 | Syntax::List syntax() | 28 | namespace CoreSyntax |
33 | { | 29 | { |
34 | Syntax::List syntax; | ||
35 | syntax << Syntax("exit", QObject::tr("Exits the application. Ctrl-d also works!"), &CoreSyntax::exit); | ||
36 | |||
37 | Syntax help(QObject::tr("help"), QObject::tr("Print command information: help [command]"), &CoreSyntax::showHelp); | ||
38 | help.completer = &CoreSyntax::showHelpCompleter; | ||
39 | syntax << help; | ||
40 | |||
41 | Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the session")); | ||
42 | set.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); | ||
43 | syntax << set; | ||
44 | |||
45 | Syntax get(QObject::tr("get"), QObject::tr("Gets settings for the session")); | ||
46 | get.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::printDebugLevel); | ||
47 | syntax << get; | ||
48 | |||
49 | return syntax; | ||
50 | } | ||
51 | 30 | ||
52 | bool exit(const QStringList &, State &) | 31 | bool exit(const QStringList &, State &) |
53 | { | 32 | { |
@@ -137,5 +116,27 @@ bool printDebugLevel(const QStringList &commands, State &state) | |||
137 | return true; | 116 | return true; |
138 | } | 117 | } |
139 | 118 | ||
119 | Syntax::List syntax() | ||
120 | { | ||
121 | Syntax::List syntax; | ||
122 | syntax << Syntax("exit", QObject::tr("Exits the application. Ctrl-d also works!"), &CoreSyntax::exit); | ||
123 | |||
124 | Syntax help(QObject::tr("help"), QObject::tr("Print command information: help [command]"), &CoreSyntax::showHelp); | ||
125 | help.completer = &CoreSyntax::showHelpCompleter; | ||
126 | syntax << help; | ||
127 | |||
128 | Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the session")); | ||
129 | set.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); | ||
130 | syntax << set; | ||
131 | |||
132 | Syntax get(QObject::tr("get"), QObject::tr("Gets settings for the session")); | ||
133 | get.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::printDebugLevel); | ||
134 | syntax << get; | ||
135 | |||
136 | return syntax; | ||
137 | } | ||
138 | |||
139 | REGISTER_SYNTAX(CoreSyntax) | ||
140 | |||
140 | } // namespace CoreSyntax | 141 | } // namespace CoreSyntax |
141 | 142 | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include "syntaxtree.h" | ||
23 | |||
24 | namespace CoreSyntax | ||
25 | { | ||
26 | Syntax::List syntax(); | ||
27 | bool exit(const QStringList &commands, State &state); | ||
28 | bool showHelp(const QStringList &commands, State &state); | ||
29 | QStringList showHelpCompleter(const QStringList &commands, const QString &fragment); | ||
30 | bool setDebugLevel(const QStringList &commands, State &state); | ||
31 | bool printDebugLevel(const QStringList &commands, State &state); | ||
32 | } | ||
33 | |||