diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-13 14:58:34 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-13 14:58:34 -0600 |
commit | 1c455b9a0b6d5a7abb0e8e9ab68e338c62811d24 (patch) | |
tree | fc7d8055e46c4b943f126907f827f7edaef7eea9 /sinksh/syntax_modules | |
parent | bfc3abb10f8827c5753a8a90a2010f0bfd3a4f10 (diff) | |
download | sink-1c455b9a0b6d5a7abb0e8e9ab68e338c62811d24.tar.gz sink-1c455b9a0b6d5a7abb0e8e9ab68e338c62811d24.zip |
sinksh show cleanup
Diffstat (limited to 'sinksh/syntax_modules')
-rw-r--r-- | sinksh/syntax_modules/sink_show.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/sinksh/syntax_modules/sink_show.cpp b/sinksh/syntax_modules/sink_show.cpp index 391505a..7a4166f 100644 --- a/sinksh/syntax_modules/sink_show.cpp +++ b/sinksh/syntax_modules/sink_show.cpp | |||
@@ -18,18 +18,12 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <QCoreApplication> | ||
22 | #include <QDebug> | 21 | #include <QDebug> |
23 | #include <QObject> // tr() | 22 | #include <QObject> // tr() |
24 | #include <QModelIndex> | 23 | #include <QModelIndex> |
25 | #include <QTime> | 24 | #include <QTime> |
26 | 25 | ||
27 | #include "common/resource.h" | ||
28 | #include "common/storage.h" | 26 | #include "common/storage.h" |
29 | #include "common/resourceconfig.h" | ||
30 | #include "common/log.h" | ||
31 | #include "common/storage.h" | ||
32 | #include "common/definitions.h" | ||
33 | 27 | ||
34 | #include "sinksh_utils.h" | 28 | #include "sinksh_utils.h" |
35 | #include "state.h" | 29 | #include "state.h" |
@@ -41,25 +35,24 @@ namespace SinkShow | |||
41 | bool show(const QStringList &args, State &state) | 35 | bool show(const QStringList &args, State &state) |
42 | { | 36 | { |
43 | if (args.isEmpty()) { | 37 | if (args.isEmpty()) { |
44 | state.printError(QObject::tr("Please provide at least one type to show (e.g. resource, ..")); | 38 | state.printError(QObject::tr("Options: $type --resource $resource --id $id")); |
45 | return false; | 39 | return false; |
46 | } | 40 | } |
47 | 41 | ||
48 | auto argList = args; | 42 | auto options = SyntaxTree::parseOptions(args); |
49 | if (argList.size() < 2 || !SinkshUtils::isValidStoreType(argList.at(0))) { | 43 | |
44 | auto type = options.positionalArguments.isEmpty() ? QString{} : options.positionalArguments.first(); | ||
45 | auto resource = options.options.value("resource"); | ||
46 | auto id = options.options.value("id"); | ||
47 | |||
48 | if (id.isEmpty() || resource.isEmpty() || !SinkshUtils::isValidStoreType(type)) { | ||
50 | state.printError(QObject::tr("Invalid command syntax. Supply type and resource at least.")); | 49 | state.printError(QObject::tr("Invalid command syntax. Supply type and resource at least.")); |
51 | return false; | 50 | return false; |
52 | } | 51 | } |
53 | auto type = argList.takeFirst(); | ||
54 | auto resource = argList.takeFirst(); | ||
55 | bool queryForResourceOrAgent = argList.isEmpty(); | ||
56 | 52 | ||
57 | Sink::Query query; | 53 | Sink::Query query; |
58 | if (queryForResourceOrAgent) { | 54 | query.resourceFilter(resource.first().toLatin1()); |
59 | query.filter(resource.toLatin1()); | 55 | query.filter(id.first().toLatin1()); |
60 | } else { | ||
61 | query.resourceFilter(resource.toLatin1()); | ||
62 | } | ||
63 | 56 | ||
64 | QTime time; | 57 | QTime time; |
65 | time.start(); | 58 | time.start(); |