diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_livequery.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_livequery.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/sinksh/syntax_modules/sink_livequery.cpp b/sinksh/syntax_modules/sink_livequery.cpp index e9e85ec..0acaaeb 100644 --- a/sinksh/syntax_modules/sink_livequery.cpp +++ b/sinksh/syntax_modules/sink_livequery.cpp | |||
@@ -38,10 +38,30 @@ | |||
38 | namespace SinkLiveQuery | 38 | namespace SinkLiveQuery |
39 | { | 39 | { |
40 | 40 | ||
41 | bool livequery(const QStringList &args_, State &state); | ||
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 | |||
41 | bool livequery(const QStringList &args_, State &state) | 61 | bool livequery(const QStringList &args_, State &state) |
42 | { | 62 | { |
43 | if (args_.isEmpty()) { | 63 | if (args_.isEmpty()) { |
44 | state.printError(QObject::tr("Options: $type [--resource $resource] [--compact] [--filter $property=$value] [--id $id] [--showall|--show $property]")); | 64 | state.printError(syntax()[0].usage()); |
45 | return false; | 65 | return false; |
46 | } | 66 | } |
47 | 67 | ||
@@ -55,7 +75,7 @@ bool livequery(const QStringList &args_, State &state) | |||
55 | query.setId("livequery"); | 75 | query.setId("livequery"); |
56 | query.setFlags(Sink::Query::LiveQuery); | 76 | query.setFlags(Sink::Query::LiveQuery); |
57 | if (!SinkshUtils::applyFilter(query, options)) { | 77 | if (!SinkshUtils::applyFilter(query, options)) { |
58 | state.printError(QObject::tr("Options: $type [--resource $resource] [--compact] [--filter $property=$value] [--showall|--show $property]")); | 78 | state.printError(syntax()[0].usage()); |
59 | return false; | 79 | return false; |
60 | } | 80 | } |
61 | if (options.options.contains("resource")) { | 81 | if (options.options.contains("resource")) { |
@@ -121,13 +141,4 @@ bool livequery(const QStringList &args_, State &state) | |||
121 | return false; | 141 | return false; |
122 | } | 142 | } |
123 | 143 | ||
124 | Syntax::List syntax() | ||
125 | { | ||
126 | Syntax list("livequery", QObject::tr("Run a livequery."), &SinkLiveQuery::livequery, Syntax::EventDriven); | ||
127 | list.completer = &SinkshUtils::resourceOrTypeCompleter; | ||
128 | return Syntax::List() << list; | ||
129 | } | ||
130 | |||
131 | REGISTER_SYNTAX(SinkLiveQuery) | ||
132 | |||
133 | } | 144 | } |