diff options
Diffstat (limited to 'sinksh/syntax_modules')
-rw-r--r-- | sinksh/syntax_modules/sink_clear.cpp | 28 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_count.cpp | 30 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_create.cpp | 73 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_drop.cpp | 24 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_inspect.cpp | 50 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_list.cpp | 44 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_livequery.cpp | 38 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_modify.cpp | 49 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_remove.cpp | 55 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_selftest.cpp | 18 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_stat.cpp | 38 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_sync.cpp | 32 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_trace.cpp | 40 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_upgrade.cpp | 16 |
14 files changed, 258 insertions, 277 deletions
diff --git a/sinksh/syntax_modules/sink_clear.cpp b/sinksh/syntax_modules/sink_clear.cpp index 536e9df..ca38943 100644 --- a/sinksh/syntax_modules/sink_clear.cpp +++ b/sinksh/syntax_modules/sink_clear.cpp | |||
@@ -35,20 +35,7 @@ | |||
35 | namespace SinkClear | 35 | namespace SinkClear |
36 | { | 36 | { |
37 | 37 | ||
38 | bool clear(const QStringList &args, State &state); | 38 | Syntax::List syntax(); |
39 | |||
40 | Syntax::List syntax() | ||
41 | { | ||
42 | Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear, Syntax::NotInteractive); | ||
43 | |||
44 | clear.addPositionalArgument({.name = "resource", .help = "The resource to clear"}); | ||
45 | |||
46 | clear.completer = &SinkshUtils::resourceCompleter; | ||
47 | |||
48 | return Syntax::List() << clear; | ||
49 | } | ||
50 | |||
51 | REGISTER_SYNTAX(SinkClear) | ||
52 | 39 | ||
53 | bool clear(const QStringList &args, State &state) | 40 | bool clear(const QStringList &args, State &state) |
54 | { | 41 | { |
@@ -65,4 +52,17 @@ bool clear(const QStringList &args, State &state) | |||
65 | return true; | 52 | return true; |
66 | } | 53 | } |
67 | 54 | ||
55 | Syntax::List syntax() | ||
56 | { | ||
57 | Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear, Syntax::NotInteractive); | ||
58 | |||
59 | clear.addPositionalArgument({.name = "resource", .help = "The resource to clear"}); | ||
60 | |||
61 | clear.completer = &SinkshUtils::resourceCompleter; | ||
62 | |||
63 | return Syntax::List() << clear; | ||
64 | } | ||
65 | |||
66 | REGISTER_SYNTAX(SinkClear) | ||
67 | |||
68 | } | 68 | } |
diff --git a/sinksh/syntax_modules/sink_count.cpp b/sinksh/syntax_modules/sink_count.cpp index aaa9c33..1edf1c2 100644 --- a/sinksh/syntax_modules/sink_count.cpp +++ b/sinksh/syntax_modules/sink_count.cpp | |||
@@ -37,21 +37,7 @@ | |||
37 | namespace SinkCount | 37 | namespace SinkCount |
38 | { | 38 | { |
39 | 39 | ||
40 | bool count(const QStringList &args, State &state); | 40 | Syntax::List syntax(); |
41 | |||
42 | Syntax::List syntax() | ||
43 | { | ||
44 | Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource"), &SinkCount::count, Syntax::EventDriven); | ||
45 | |||
46 | count.addPositionalArgument({.name = "type", .help = "The entity type to count"}); | ||
47 | count.addPositionalArgument({.name = "resource", .help = "A resource id where to count", .required = false}); | ||
48 | |||
49 | count.completer = &SinkshUtils::typeCompleter; | ||
50 | |||
51 | return Syntax::List() << count; | ||
52 | } | ||
53 | |||
54 | REGISTER_SYNTAX(SinkCount) | ||
55 | 41 | ||
56 | bool count(const QStringList &args, State &state) | 42 | bool count(const QStringList &args, State &state) |
57 | { | 43 | { |
@@ -77,4 +63,18 @@ bool count(const QStringList &args, State &state) | |||
77 | return true; | 63 | return true; |
78 | } | 64 | } |
79 | 65 | ||
66 | Syntax::List syntax() | ||
67 | { | ||
68 | Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource"), &SinkCount::count, Syntax::EventDriven); | ||
69 | |||
70 | count.addPositionalArgument({.name = "type", .help = "The entity type to count"}); | ||
71 | count.addPositionalArgument({.name = "resource", .help = "A resource id where to count", .required = false}); | ||
72 | |||
73 | count.completer = &SinkshUtils::typeCompleter; | ||
74 | |||
75 | return Syntax::List() << count; | ||
76 | } | ||
77 | |||
78 | REGISTER_SYNTAX(SinkCount) | ||
79 | |||
80 | } | 80 | } |
diff --git a/sinksh/syntax_modules/sink_create.cpp b/sinksh/syntax_modules/sink_create.cpp index b7025cc..b1631cd 100644 --- a/sinksh/syntax_modules/sink_create.cpp +++ b/sinksh/syntax_modules/sink_create.cpp | |||
@@ -40,44 +40,7 @@ using namespace Sink; | |||
40 | namespace SinkCreate | 40 | namespace SinkCreate |
41 | { | 41 | { |
42 | 42 | ||
43 | bool create(const QStringList &allArgs, State &state); | 43 | Syntax::List syntax(); |
44 | bool resource(const QStringList &args, State &state); | ||
45 | bool account(const QStringList &args, State &state); | ||
46 | bool identity(const QStringList &args, State &state); | ||
47 | |||
48 | Syntax::List syntax() | ||
49 | { | ||
50 | Syntax::List syntax; | ||
51 | |||
52 | Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); | ||
53 | create.addPositionalArgument({ .name = "type", .help = "The type of entity to create (mail, event, etc.)" }); | ||
54 | create.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource that will contain the new entity" }); | ||
55 | create.addPositionalArgument( | ||
56 | { .name = "key value", .help = "Content of the entity", .required = false, .variadic = true }); | ||
57 | |||
58 | Syntax resource("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); | ||
59 | resource.addPositionalArgument({ .name = "type", .help = "The type of resource to create" }); | ||
60 | resource.addPositionalArgument( | ||
61 | { .name = "key value", .help = "Content of the resource", .required = false, .variadic = true }); | ||
62 | |||
63 | Syntax account("account", QObject::tr("Creates a new account"), &SinkCreate::account); | ||
64 | account.addPositionalArgument({ .name = "type", .help = "The type of account to create" }); | ||
65 | account.addPositionalArgument( | ||
66 | { .name = "key value", .help = "Content of the account", .required = false, .variadic = true }); | ||
67 | |||
68 | Syntax identity("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity); | ||
69 | identity.addPositionalArgument( | ||
70 | { .name = "key value", .help = "Content of the identity", .required = false, .variadic = true }); | ||
71 | |||
72 | create.children << resource; | ||
73 | create.children << account; | ||
74 | create.children << identity; | ||
75 | |||
76 | syntax << create; | ||
77 | return syntax; | ||
78 | } | ||
79 | |||
80 | REGISTER_SYNTAX(SinkCreate) | ||
81 | 44 | ||
82 | bool create(const QStringList &allArgs, State &state) | 45 | bool create(const QStringList &allArgs, State &state) |
83 | { | 46 | { |
@@ -207,4 +170,38 @@ bool identity(const QStringList &args, State &state) | |||
207 | return true; | 170 | return true; |
208 | } | 171 | } |
209 | 172 | ||
173 | Syntax::List syntax() | ||
174 | { | ||
175 | Syntax::List syntax; | ||
176 | |||
177 | Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); | ||
178 | create.addPositionalArgument({ .name = "type", .help = "The type of entity to create (mail, event, etc.)" }); | ||
179 | create.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource that will contain the new entity" }); | ||
180 | create.addPositionalArgument( | ||
181 | { .name = "key value", .help = "Content of the entity", .required = false, .variadic = true }); | ||
182 | |||
183 | Syntax resource("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); | ||
184 | resource.addPositionalArgument({ .name = "type", .help = "The type of resource to create" }); | ||
185 | resource.addPositionalArgument( | ||
186 | { .name = "key value", .help = "Content of the resource", .required = false, .variadic = true }); | ||
187 | |||
188 | Syntax account("account", QObject::tr("Creates a new account"), &SinkCreate::account); | ||
189 | account.addPositionalArgument({ .name = "type", .help = "The type of account to create" }); | ||
190 | account.addPositionalArgument( | ||
191 | { .name = "key value", .help = "Content of the account", .required = false, .variadic = true }); | ||
192 | |||
193 | Syntax identity("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity); | ||
194 | identity.addPositionalArgument( | ||
195 | { .name = "key value", .help = "Content of the identity", .required = false, .variadic = true }); | ||
196 | |||
197 | create.children << resource; | ||
198 | create.children << account; | ||
199 | create.children << identity; | ||
200 | |||
201 | syntax << create; | ||
202 | return syntax; | ||
203 | } | ||
204 | |||
205 | REGISTER_SYNTAX(SinkCreate) | ||
206 | |||
210 | } | 207 | } |
diff --git a/sinksh/syntax_modules/sink_drop.cpp b/sinksh/syntax_modules/sink_drop.cpp index 2353ed1..eaa3041 100644 --- a/sinksh/syntax_modules/sink_drop.cpp +++ b/sinksh/syntax_modules/sink_drop.cpp | |||
@@ -35,18 +35,7 @@ | |||
35 | namespace SinkDrop | 35 | namespace SinkDrop |
36 | { | 36 | { |
37 | 37 | ||
38 | bool drop(const QStringList &args, State &state); | 38 | Syntax::List syntax(); |
39 | |||
40 | Syntax::List syntax() | ||
41 | { | ||
42 | Syntax drop("drop", QObject::tr("Drop all caches of a resource."), &SinkDrop::drop, Syntax::NotInteractive); | ||
43 | drop.addPositionalArgument({.name = "resource", .help = "Id(s) of the resource(s) to drop", .required = true, .variadic = true}); | ||
44 | |||
45 | drop.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
46 | return Syntax::List() << drop; | ||
47 | } | ||
48 | |||
49 | REGISTER_SYNTAX(SinkDrop) | ||
50 | 39 | ||
51 | bool drop(const QStringList &args, State &state) | 40 | bool drop(const QStringList &args, State &state) |
52 | { | 41 | { |
@@ -70,4 +59,15 @@ bool drop(const QStringList &args, State &state) | |||
70 | return false; | 59 | return false; |
71 | } | 60 | } |
72 | 61 | ||
62 | Syntax::List syntax() | ||
63 | { | ||
64 | Syntax drop("drop", QObject::tr("Drop all caches of a resource."), &SinkDrop::drop, Syntax::NotInteractive); | ||
65 | drop.addPositionalArgument({.name = "resource", .help = "Id(s) of the resource(s) to drop", .required = true, .variadic = true}); | ||
66 | |||
67 | drop.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
68 | return Syntax::List() << drop; | ||
69 | } | ||
70 | |||
71 | REGISTER_SYNTAX(SinkDrop) | ||
72 | |||
73 | } | 73 | } |
diff --git a/sinksh/syntax_modules/sink_inspect.cpp b/sinksh/syntax_modules/sink_inspect.cpp index d952a9b..355efa3 100644 --- a/sinksh/syntax_modules/sink_inspect.cpp +++ b/sinksh/syntax_modules/sink_inspect.cpp | |||
@@ -55,31 +55,7 @@ QString parse(const QByteArray &bytes) | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | bool inspect(const QStringList &args, State &state); | 58 | Syntax::List syntax(); |
59 | |||
60 | Syntax::List syntax() | ||
61 | { | ||
62 | Syntax state("inspect", QObject::tr("Inspect database for the resource requested"), | ||
63 | &SinkInspect::inspect, Syntax::NotInteractive); | ||
64 | |||
65 | state.addParameter("resource", | ||
66 | { .name = "resource", .help = "Which resource to inspect", .required = true }); | ||
67 | state.addParameter("db", | ||
68 | { .name = "database", .help = "Which database to inspect"}); | ||
69 | state.addParameter("filter", | ||
70 | { .name = "id", .help = "A specific id to filter the results by (currently not working)"}); | ||
71 | state.addFlag("showinternal", "Show internal fields only"); | ||
72 | state.addParameter("validaterids", | ||
73 | { .name = "type", .help = "Validate remote Ids of the given type"}); | ||
74 | state.addParameter("fulltext", | ||
75 | { .name = "id", .help = "If 'id' is not given, count the number of fulltext documents. Else, print the terms of the document with the given id"}); | ||
76 | |||
77 | state.completer = &SinkshUtils::resourceCompleter; | ||
78 | |||
79 | return Syntax::List() << state; | ||
80 | } | ||
81 | |||
82 | REGISTER_SYNTAX(SinkInspect) | ||
83 | 59 | ||
84 | bool inspect(const QStringList &args, State &state) | 60 | bool inspect(const QStringList &args, State &state) |
85 | { | 61 | { |
@@ -262,4 +238,28 @@ bool inspect(const QStringList &args, State &state) | |||
262 | return false; | 238 | return false; |
263 | } | 239 | } |
264 | 240 | ||
241 | Syntax::List syntax() | ||
242 | { | ||
243 | Syntax state("inspect", QObject::tr("Inspect database for the resource requested"), | ||
244 | &SinkInspect::inspect, Syntax::NotInteractive); | ||
245 | |||
246 | state.addParameter("resource", | ||
247 | { .name = "resource", .help = "Which resource to inspect", .required = true }); | ||
248 | state.addParameter("db", | ||
249 | { .name = "database", .help = "Which database to inspect"}); | ||
250 | state.addParameter("filter", | ||
251 | { .name = "id", .help = "A specific id to filter the results by (currently not working)"}); | ||
252 | state.addFlag("showinternal", "Show internal fields only"); | ||
253 | state.addParameter("validaterids", | ||
254 | { .name = "type", .help = "Validate remote Ids of the given type"}); | ||
255 | state.addParameter("fulltext", | ||
256 | { .name = "id", .help = "If 'id' is not given, count the number of fulltext documents. Else, print the terms of the document with the given id"}); | ||
257 | |||
258 | state.completer = &SinkshUtils::resourceCompleter; | ||
259 | |||
260 | return Syntax::List() << state; | ||
261 | } | ||
262 | |||
263 | REGISTER_SYNTAX(SinkInspect) | ||
264 | |||
265 | } | 265 | } |
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index c091cd4..903dc2a 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp | |||
@@ -39,28 +39,7 @@ | |||
39 | namespace SinkList | 39 | namespace SinkList |
40 | { | 40 | { |
41 | 41 | ||
42 | bool list(const QStringList &args_, State &state); | 42 | Syntax::List syntax(); |
43 | |||
44 | Syntax::List syntax() | ||
45 | { | ||
46 | Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources."), &SinkList::list, Syntax::NotInteractive); | ||
47 | |||
48 | list.addPositionalArgument({.name = "type", .help = "The type of content to list (resource, identity, account, mail, etc.)"}); | ||
49 | list.addParameter("resource", { .name = "resource", .help = "List only the content of the given resource" }); | ||
50 | list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); | ||
51 | list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); | ||
52 | list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); | ||
53 | list.addFlag("showall", "Show all properties"); | ||
54 | list.addParameter("show", { .name = "property", .help = "Only show the given property" }); | ||
55 | list.addParameter("reduce", { .name = "property:$selectorProperty", .help = "Combine the result with the same $property, sorted by $selectorProperty" }); | ||
56 | list.addParameter("sort", { .name = "property", .help = "Sort the results according to the given property" }); | ||
57 | list.addParameter("limit", { .name = "count", .help = "Limit the results" }); | ||
58 | |||
59 | list.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
60 | return Syntax::List() << list; | ||
61 | } | ||
62 | |||
63 | REGISTER_SYNTAX(SinkList) | ||
64 | 43 | ||
65 | static QByteArray compressId(bool compress, const QByteArray &id) | 44 | static QByteArray compressId(bool compress, const QByteArray &id) |
66 | { | 45 | { |
@@ -216,4 +195,25 @@ bool list(const QStringList &args_, State &state) | |||
216 | return true; | 195 | return true; |
217 | } | 196 | } |
218 | 197 | ||
198 | Syntax::List syntax() | ||
199 | { | ||
200 | Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources."), &SinkList::list, Syntax::NotInteractive); | ||
201 | |||
202 | list.addPositionalArgument({.name = "type", .help = "The type of content to list (resource, identity, account, mail, etc.)"}); | ||
203 | list.addParameter("resource", { .name = "resource", .help = "List only the content of the given resource" }); | ||
204 | list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); | ||
205 | list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); | ||
206 | list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); | ||
207 | list.addFlag("showall", "Show all properties"); | ||
208 | list.addParameter("show", { .name = "property", .help = "Only show the given property" }); | ||
209 | list.addParameter("reduce", { .name = "property:$selectorProperty", .help = "Combine the result with the same $property, sorted by $selectorProperty" }); | ||
210 | list.addParameter("sort", { .name = "property", .help = "Sort the results according to the given property" }); | ||
211 | list.addParameter("limit", { .name = "count", .help = "Limit the results" }); | ||
212 | |||
213 | list.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
214 | return Syntax::List() << list; | ||
215 | } | ||
216 | |||
217 | REGISTER_SYNTAX(SinkList) | ||
218 | |||
219 | } | 219 | } |
diff --git a/sinksh/syntax_modules/sink_livequery.cpp b/sinksh/syntax_modules/sink_livequery.cpp index 0acaaeb..2d8d5d0 100644 --- a/sinksh/syntax_modules/sink_livequery.cpp +++ b/sinksh/syntax_modules/sink_livequery.cpp | |||
@@ -38,25 +38,7 @@ | |||
38 | namespace SinkLiveQuery | 38 | namespace SinkLiveQuery |
39 | { | 39 | { |
40 | 40 | ||
41 | bool livequery(const QStringList &args_, State &state); | 41 | Syntax::List syntax(); |
42 | |||
43 | Syntax::List syntax() | ||
44 | { | ||
45 | Syntax list("livequery", QObject::tr("Run a livequery."), &SinkLiveQuery::livequery, Syntax::EventDriven); | ||
46 | |||
47 | list.addPositionalArgument({ .name = "type", .help = "The type to run the livequery on" }); | ||
48 | list.addParameter("resource", { .name = "resource", .help = "Filter the livequery to the given resource" }); | ||
49 | list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); | ||
50 | list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); | ||
51 | list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); | ||
52 | list.addFlag("showall", "Show all properties"); | ||
53 | list.addParameter("show", { .name = "property", .help = "Only show the given property" }); | ||
54 | |||
55 | list.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
56 | return Syntax::List() << list; | ||
57 | } | ||
58 | |||
59 | REGISTER_SYNTAX(SinkLiveQuery) | ||
60 | 42 | ||
61 | bool livequery(const QStringList &args_, State &state) | 43 | bool livequery(const QStringList &args_, State &state) |
62 | { | 44 | { |
@@ -141,4 +123,22 @@ bool livequery(const QStringList &args_, State &state) | |||
141 | return false; | 123 | return false; |
142 | } | 124 | } |
143 | 125 | ||
126 | Syntax::List syntax() | ||
127 | { | ||
128 | Syntax list("livequery", QObject::tr("Run a livequery."), &SinkLiveQuery::livequery, Syntax::EventDriven); | ||
129 | |||
130 | list.addPositionalArgument({ .name = "type", .help = "The type to run the livequery on" }); | ||
131 | list.addParameter("resource", { .name = "resource", .help = "Filter the livequery to the given resource" }); | ||
132 | list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); | ||
133 | list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); | ||
134 | list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); | ||
135 | list.addFlag("showall", "Show all properties"); | ||
136 | list.addParameter("show", { .name = "property", .help = "Only show the given property" }); | ||
137 | |||
138 | list.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
139 | return Syntax::List() << list; | ||
140 | } | ||
141 | |||
142 | REGISTER_SYNTAX(SinkLiveQuery) | ||
143 | |||
144 | } | 144 | } |
diff --git a/sinksh/syntax_modules/sink_modify.cpp b/sinksh/syntax_modules/sink_modify.cpp index cd29d56..6cda5ab 100644 --- a/sinksh/syntax_modules/sink_modify.cpp +++ b/sinksh/syntax_modules/sink_modify.cpp | |||
@@ -38,31 +38,7 @@ | |||
38 | namespace SinkModify | 38 | namespace SinkModify |
39 | { | 39 | { |
40 | 40 | ||
41 | bool modify(const QStringList &args, State &state); | 41 | Syntax::List syntax(); |
42 | bool resource(const QStringList &args, State &state); | ||
43 | |||
44 | Syntax::List syntax() | ||
45 | { | ||
46 | Syntax modify("modify", QObject::tr("Modify items in a resource"), &SinkModify::modify); | ||
47 | modify.addPositionalArgument({ .name = "type", .help = "The type of entity to modify (mail, event, etc.)" }); | ||
48 | modify.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); | ||
49 | modify.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity" }); | ||
50 | modify.addPositionalArgument( | ||
51 | { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); | ||
52 | |||
53 | Syntax resource("resource", QObject::tr("Modify a resource"), &SinkModify::resource);//, Syntax::EventDriven); | ||
54 | |||
55 | resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource" }); | ||
56 | resource.addPositionalArgument( | ||
57 | { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); | ||
58 | |||
59 | resource.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
60 | modify.children << resource; | ||
61 | |||
62 | return Syntax::List() << modify; | ||
63 | } | ||
64 | |||
65 | REGISTER_SYNTAX(SinkModify) | ||
66 | 42 | ||
67 | bool modify(const QStringList &args, State &state) | 43 | bool modify(const QStringList &args, State &state) |
68 | { | 44 | { |
@@ -122,4 +98,27 @@ bool resource(const QStringList &args, State &state) | |||
122 | return true; | 98 | return true; |
123 | } | 99 | } |
124 | 100 | ||
101 | Syntax::List syntax() | ||
102 | { | ||
103 | Syntax modify("modify", QObject::tr("Modify items in a resource"), &SinkModify::modify); | ||
104 | modify.addPositionalArgument({ .name = "type", .help = "The type of entity to modify (mail, event, etc.)" }); | ||
105 | modify.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); | ||
106 | modify.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity" }); | ||
107 | modify.addPositionalArgument( | ||
108 | { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); | ||
109 | |||
110 | Syntax resource("resource", QObject::tr("Modify a resource"), &SinkModify::resource);//, Syntax::EventDriven); | ||
111 | |||
112 | resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource" }); | ||
113 | resource.addPositionalArgument( | ||
114 | { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); | ||
115 | |||
116 | resource.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
117 | modify.children << resource; | ||
118 | |||
119 | return Syntax::List() << modify; | ||
120 | } | ||
121 | |||
122 | REGISTER_SYNTAX(SinkModify) | ||
123 | |||
125 | } | 124 | } |
diff --git a/sinksh/syntax_modules/sink_remove.cpp b/sinksh/syntax_modules/sink_remove.cpp index f948290..999a889 100644 --- a/sinksh/syntax_modules/sink_remove.cpp +++ b/sinksh/syntax_modules/sink_remove.cpp | |||
@@ -37,35 +37,7 @@ | |||
37 | namespace SinkRemove | 37 | namespace SinkRemove |
38 | { | 38 | { |
39 | 39 | ||
40 | bool remove(const QStringList &args, State &state); | 40 | Syntax::List syntax(); |
41 | bool resource(const QStringList &args, State &state); | ||
42 | bool account(const QStringList &args, State &state); | ||
43 | bool identity(const QStringList &args, State &state); | ||
44 | |||
45 | Syntax::List syntax() | ||
46 | { | ||
47 | Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); | ||
48 | |||
49 | remove.addPositionalArgument({ .name = "type", .help = "The type of entity to remove (mail, event, etc.)" }); | ||
50 | remove.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); | ||
51 | remove.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity to remove" }); | ||
52 | |||
53 | Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource, Syntax::NotInteractive); | ||
54 | resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource to remove" }); | ||
55 | resource.completer = &SinkshUtils::resourceCompleter; | ||
56 | |||
57 | Syntax account("account", QObject::tr("Removes a account"), &SinkRemove::account, Syntax::NotInteractive); | ||
58 | account.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); | ||
59 | |||
60 | Syntax identity("identity", QObject::tr("Removes an identity"), &SinkRemove::identity, Syntax::NotInteractive); | ||
61 | identity.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); | ||
62 | |||
63 | remove.children << resource << account << identity; | ||
64 | |||
65 | return Syntax::List() << remove; | ||
66 | } | ||
67 | |||
68 | REGISTER_SYNTAX(SinkRemove) | ||
69 | 41 | ||
70 | bool remove(const QStringList &args, State &state) | 42 | bool remove(const QStringList &args, State &state) |
71 | { | 43 | { |
@@ -157,4 +129,29 @@ bool identity(const QStringList &args, State &state) | |||
157 | return true; | 129 | return true; |
158 | } | 130 | } |
159 | 131 | ||
132 | Syntax::List syntax() | ||
133 | { | ||
134 | Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); | ||
135 | |||
136 | remove.addPositionalArgument({ .name = "type", .help = "The type of entity to remove (mail, event, etc.)" }); | ||
137 | remove.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); | ||
138 | remove.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity to remove" }); | ||
139 | |||
140 | Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource, Syntax::NotInteractive); | ||
141 | resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource to remove" }); | ||
142 | resource.completer = &SinkshUtils::resourceCompleter; | ||
143 | |||
144 | Syntax account("account", QObject::tr("Removes a account"), &SinkRemove::account, Syntax::NotInteractive); | ||
145 | account.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); | ||
146 | |||
147 | Syntax identity("identity", QObject::tr("Removes an identity"), &SinkRemove::identity, Syntax::NotInteractive); | ||
148 | identity.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); | ||
149 | |||
150 | remove.children << resource << account << identity; | ||
151 | |||
152 | return Syntax::List() << remove; | ||
153 | } | ||
154 | |||
155 | REGISTER_SYNTAX(SinkRemove) | ||
156 | |||
160 | } | 157 | } |
diff --git a/sinksh/syntax_modules/sink_selftest.cpp b/sinksh/syntax_modules/sink_selftest.cpp index 132b952..a1c7dcb 100644 --- a/sinksh/syntax_modules/sink_selftest.cpp +++ b/sinksh/syntax_modules/sink_selftest.cpp | |||
@@ -41,16 +41,6 @@ | |||
41 | namespace SinkSelfTest | 41 | namespace SinkSelfTest |
42 | { | 42 | { |
43 | 43 | ||
44 | bool selfTest(const QStringList &args_, State &state); | ||
45 | |||
46 | Syntax::List syntax() | ||
47 | { | ||
48 | Syntax syntax("selftest", QObject::tr("A selftest module."), &SinkSelfTest::selfTest, Syntax::EventDriven); | ||
49 | return Syntax::List() << syntax; | ||
50 | } | ||
51 | |||
52 | REGISTER_SYNTAX(SinkSelfTest) | ||
53 | |||
54 | bool selfTest(const QStringList &args_, State &state) | 44 | bool selfTest(const QStringList &args_, State &state) |
55 | { | 45 | { |
56 | using namespace Sink::ApplicationDomain; | 46 | using namespace Sink::ApplicationDomain; |
@@ -164,4 +154,12 @@ bool selfTest(const QStringList &args_, State &state) | |||
164 | return false; | 154 | return false; |
165 | } | 155 | } |
166 | 156 | ||
157 | Syntax::List syntax() | ||
158 | { | ||
159 | Syntax syntax("selftest", QObject::tr("A selftest module."), &SinkSelfTest::selfTest, Syntax::EventDriven); | ||
160 | return Syntax::List() << syntax; | ||
161 | } | ||
162 | |||
163 | REGISTER_SYNTAX(SinkSelfTest) | ||
164 | |||
167 | } | 165 | } |
diff --git a/sinksh/syntax_modules/sink_stat.cpp b/sinksh/syntax_modules/sink_stat.cpp index 235558f..a936af2 100644 --- a/sinksh/syntax_modules/sink_stat.cpp +++ b/sinksh/syntax_modules/sink_stat.cpp | |||
@@ -36,26 +36,6 @@ | |||
36 | namespace SinkStat | 36 | namespace SinkStat |
37 | { | 37 | { |
38 | 38 | ||
39 | bool stat(const QStringList &args, State &state); | ||
40 | |||
41 | Syntax::List syntax() | ||
42 | { | ||
43 | Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), | ||
44 | &SinkStat::stat, Syntax::NotInteractive); | ||
45 | |||
46 | state.addPositionalArgument({ .name = "resourceId", | ||
47 | .help = "Show statistics of the given resource(s). If no resource is provided, show " | ||
48 | "statistics of all resources", | ||
49 | .required = false, | ||
50 | .variadic = true }); | ||
51 | |||
52 | state.completer = &SinkshUtils::resourceCompleter; | ||
53 | |||
54 | return Syntax::List() << state; | ||
55 | } | ||
56 | |||
57 | REGISTER_SYNTAX(SinkStat) | ||
58 | |||
59 | void statResource(const QString &resource, const State &state) | 39 | void statResource(const QString &resource, const State &state) |
60 | { | 40 | { |
61 | state.printLine("Resource " + resource + ":"); | 41 | state.printLine("Resource " + resource + ":"); |
@@ -119,4 +99,22 @@ bool stat(const QStringList &args, State &state) | |||
119 | return false; | 99 | return false; |
120 | } | 100 | } |
121 | 101 | ||
102 | Syntax::List syntax() | ||
103 | { | ||
104 | Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), | ||
105 | &SinkStat::stat, Syntax::NotInteractive); | ||
106 | |||
107 | state.addPositionalArgument({ .name = "resourceId", | ||
108 | .help = "Show statistics of the given resource(s). If no resource is provided, show " | ||
109 | "statistics of all resources", | ||
110 | .required = false, | ||
111 | .variadic = true }); | ||
112 | |||
113 | state.completer = &SinkshUtils::resourceCompleter; | ||
114 | |||
115 | return Syntax::List() << state; | ||
116 | } | ||
117 | |||
118 | REGISTER_SYNTAX(SinkStat) | ||
119 | |||
122 | } | 120 | } |
diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp index ee19f0a..e13e8f8 100644 --- a/sinksh/syntax_modules/sink_sync.cpp +++ b/sinksh/syntax_modules/sink_sync.cpp | |||
@@ -37,23 +37,6 @@ | |||
37 | namespace SinkSync | 37 | namespace SinkSync |
38 | { | 38 | { |
39 | 39 | ||
40 | bool sync(const QStringList &args, State &state); | ||
41 | |||
42 | Syntax::List syntax() | ||
43 | { | ||
44 | Syntax sync("sync", QObject::tr("Synchronizes a resource."), &SinkSync::sync, Syntax::EventDriven); | ||
45 | |||
46 | sync.addPositionalArgument({ .name = "type", .help = "The type of resource to synchronize" }); | ||
47 | sync.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource to synchronize" }); | ||
48 | sync.addParameter("password", { .name = "password", .help = "The password of the resource", .required = true }); | ||
49 | |||
50 | sync.completer = &SinkshUtils::resourceCompleter; | ||
51 | |||
52 | return Syntax::List() << sync; | ||
53 | } | ||
54 | |||
55 | REGISTER_SYNTAX(SinkSync) | ||
56 | |||
57 | bool sync(const QStringList &args, State &state) | 40 | bool sync(const QStringList &args, State &state) |
58 | { | 41 | { |
59 | auto options = SyntaxTree::parseOptions(args); | 42 | auto options = SyntaxTree::parseOptions(args); |
@@ -97,4 +80,19 @@ bool sync(const QStringList &args, State &state) | |||
97 | return true; | 80 | return true; |
98 | } | 81 | } |
99 | 82 | ||
83 | Syntax::List syntax() | ||
84 | { | ||
85 | Syntax sync("sync", QObject::tr("Synchronizes a resource."), &SinkSync::sync, Syntax::EventDriven); | ||
86 | |||
87 | sync.addPositionalArgument({ .name = "type", .help = "The type of resource to synchronize" }); | ||
88 | sync.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource to synchronize" }); | ||
89 | sync.addParameter("password", { .name = "password", .help = "The password of the resource", .required = true }); | ||
90 | |||
91 | sync.completer = &SinkshUtils::resourceCompleter; | ||
92 | |||
93 | return Syntax::List() << sync; | ||
94 | } | ||
95 | |||
96 | REGISTER_SYNTAX(SinkSync) | ||
97 | |||
100 | } | 98 | } |
diff --git a/sinksh/syntax_modules/sink_trace.cpp b/sinksh/syntax_modules/sink_trace.cpp index 8636daa..2811258 100644 --- a/sinksh/syntax_modules/sink_trace.cpp +++ b/sinksh/syntax_modules/sink_trace.cpp | |||
@@ -36,28 +36,6 @@ | |||
36 | namespace SinkTrace | 36 | namespace SinkTrace |
37 | { | 37 | { |
38 | 38 | ||
39 | bool traceOff(const QStringList &args, State &state); | ||
40 | bool traceOn(const QStringList &args, State &state); | ||
41 | bool trace(const QStringList &args, State &state); | ||
42 | |||
43 | Syntax::List syntax() | ||
44 | { | ||
45 | Syntax trace("trace", QObject::tr("Control trace debug output."), &SinkTrace::trace, Syntax::NotInteractive); | ||
46 | trace.completer = &SinkshUtils::debugareaCompleter; | ||
47 | |||
48 | Syntax traceOff("off", QObject::tr("Turns off trace output."), &SinkTrace::traceOff, Syntax::NotInteractive); | ||
49 | traceOff.completer = &SinkshUtils::debugareaCompleter; | ||
50 | trace.children << traceOff; | ||
51 | |||
52 | Syntax traceOn("on", QObject::tr("Turns on trace output."), &SinkTrace::traceOn, Syntax::NotInteractive); | ||
53 | traceOn.completer = &SinkshUtils::debugareaCompleter; | ||
54 | trace.children << traceOn; | ||
55 | |||
56 | return Syntax::List() << trace; | ||
57 | } | ||
58 | |||
59 | REGISTER_SYNTAX(SinkTrace) | ||
60 | |||
61 | bool traceOff(const QStringList &args, State &state) | 39 | bool traceOff(const QStringList &args, State &state) |
62 | { | 40 | { |
63 | Sink::Log::setDebugOutputFilter(Sink::Log::Area, QByteArrayList()); | 41 | Sink::Log::setDebugOutputFilter(Sink::Log::Area, QByteArrayList()); |
@@ -88,4 +66,22 @@ bool trace(const QStringList &args, State &state) | |||
88 | return traceOn(args, state); | 66 | return traceOn(args, state); |
89 | } | 67 | } |
90 | 68 | ||
69 | Syntax::List syntax() | ||
70 | { | ||
71 | Syntax trace("trace", QObject::tr("Control trace debug output."), &SinkTrace::trace, Syntax::NotInteractive); | ||
72 | trace.completer = &SinkshUtils::debugareaCompleter; | ||
73 | |||
74 | Syntax traceOff("off", QObject::tr("Turns off trace output."), &SinkTrace::traceOff, Syntax::NotInteractive); | ||
75 | traceOff.completer = &SinkshUtils::debugareaCompleter; | ||
76 | trace.children << traceOff; | ||
77 | |||
78 | Syntax traceOn("on", QObject::tr("Turns on trace output."), &SinkTrace::traceOn, Syntax::NotInteractive); | ||
79 | traceOn.completer = &SinkshUtils::debugareaCompleter; | ||
80 | trace.children << traceOn; | ||
81 | |||
82 | return Syntax::List() << trace; | ||
83 | } | ||
84 | |||
85 | REGISTER_SYNTAX(SinkTrace) | ||
86 | |||
91 | } | 87 | } |
diff --git a/sinksh/syntax_modules/sink_upgrade.cpp b/sinksh/syntax_modules/sink_upgrade.cpp index 03c29ae..c399048 100644 --- a/sinksh/syntax_modules/sink_upgrade.cpp +++ b/sinksh/syntax_modules/sink_upgrade.cpp | |||
@@ -29,15 +29,6 @@ | |||
29 | namespace SinkUpgrade | 29 | namespace SinkUpgrade |
30 | { | 30 | { |
31 | 31 | ||
32 | bool upgrade(const QStringList &args, State &state); | ||
33 | |||
34 | Syntax::List syntax() | ||
35 | { | ||
36 | return Syntax::List() << Syntax{"upgrade", QObject::tr("Upgrades your storage to the latest version (be careful!)"), &SinkUpgrade::upgrade, Syntax::NotInteractive}; | ||
37 | } | ||
38 | |||
39 | REGISTER_SYNTAX(SinkUpgrade) | ||
40 | |||
41 | bool upgrade(const QStringList &args, State &state) | 32 | bool upgrade(const QStringList &args, State &state) |
42 | { | 33 | { |
43 | state.print(QObject::tr("Upgrading...")); | 34 | state.print(QObject::tr("Upgrading...")); |
@@ -46,4 +37,11 @@ bool upgrade(const QStringList &args, State &state) | |||
46 | return true; | 37 | return true; |
47 | } | 38 | } |
48 | 39 | ||
40 | Syntax::List syntax() | ||
41 | { | ||
42 | return Syntax::List() << Syntax{"upgrade", QObject::tr("Upgrades your storage to the latest version (be careful!)"), &SinkUpgrade::upgrade, Syntax::NotInteractive}; | ||
43 | } | ||
44 | |||
45 | REGISTER_SYNTAX(SinkUpgrade) | ||
46 | |||
49 | } | 47 | } |