diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_inspect.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_inspect.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/sinksh/syntax_modules/sink_inspect.cpp b/sinksh/syntax_modules/sink_inspect.cpp index f9cc50a..d952a9b 100644 --- a/sinksh/syntax_modules/sink_inspect.cpp +++ b/sinksh/syntax_modules/sink_inspect.cpp | |||
@@ -55,10 +55,38 @@ QString parse(const QByteArray &bytes) | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | bool inspect(const QStringList &args, State &state); | ||
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 | |||
58 | bool inspect(const QStringList &args, State &state) | 84 | bool inspect(const QStringList &args, State &state) |
59 | { | 85 | { |
60 | if (args.isEmpty()) { | 86 | if (args.isEmpty()) { |
61 | state.printError(QObject::tr("Options: [--resource $resource] ([--db $db] [--filter $id] [--showinternal] | [--validaterids $type] | [--fulltext [$id]])")); | 87 | //state.printError(QObject::tr("Options: [--resource $resource] ([--db $db] [--filter $id] [--showinternal] | [--validaterids $type] | [--fulltext [$id]])")); |
88 | state.printError(syntax()[0].usage()); | ||
89 | return false; | ||
62 | } | 90 | } |
63 | auto options = SyntaxTree::parseOptions(args); | 91 | auto options = SyntaxTree::parseOptions(args); |
64 | auto resource = SinkshUtils::parseUid(options.options.value("resource").value(0).toUtf8()); | 92 | auto resource = SinkshUtils::parseUid(options.options.value("resource").value(0).toUtf8()); |
@@ -234,14 +262,4 @@ bool inspect(const QStringList &args, State &state) | |||
234 | return false; | 262 | return false; |
235 | } | 263 | } |
236 | 264 | ||
237 | Syntax::List syntax() | ||
238 | { | ||
239 | Syntax state("inspect", QObject::tr("Inspect database for the resource requested"), &SinkInspect::inspect, Syntax::NotInteractive); | ||
240 | state.completer = &SinkshUtils::resourceCompleter; | ||
241 | |||
242 | return Syntax::List() << state; | ||
243 | } | ||
244 | |||
245 | REGISTER_SYNTAX(SinkInspect) | ||
246 | |||
247 | } | 265 | } |