diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_count.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_count.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sinksh/syntax_modules/sink_count.cpp b/sinksh/syntax_modules/sink_count.cpp index 04a9550..1edf1c2 100644 --- a/sinksh/syntax_modules/sink_count.cpp +++ b/sinksh/syntax_modules/sink_count.cpp | |||
@@ -37,12 +37,14 @@ | |||
37 | namespace SinkCount | 37 | namespace SinkCount |
38 | { | 38 | { |
39 | 39 | ||
40 | Syntax::List syntax(); | ||
41 | |||
40 | bool count(const QStringList &args, State &state) | 42 | bool count(const QStringList &args, State &state) |
41 | { | 43 | { |
42 | Sink::Query query; | 44 | Sink::Query query; |
43 | query.setId("count"); | 45 | query.setId("count"); |
44 | if (!SinkshUtils::applyFilter(query, SyntaxTree::parseOptions(args))) { | 46 | if (!SinkshUtils::applyFilter(query, SyntaxTree::parseOptions(args))) { |
45 | state.printError(QObject::tr("Options: $type $filter")); | 47 | state.printError(syntax()[0].usage()); |
46 | return false; | 48 | return false; |
47 | } | 49 | } |
48 | 50 | ||
@@ -63,7 +65,11 @@ bool count(const QStringList &args, State &state) | |||
63 | 65 | ||
64 | Syntax::List syntax() | 66 | Syntax::List syntax() |
65 | { | 67 | { |
66 | Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count <type> <resource>"), &SinkCount::count, Syntax::EventDriven); | 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 | |||
67 | count.completer = &SinkshUtils::typeCompleter; | 73 | count.completer = &SinkshUtils::typeCompleter; |
68 | 74 | ||
69 | return Syntax::List() << count; | 75 | return Syntax::List() << count; |