summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_list.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sinksh/syntax_modules/sink_list.cpp')
-rw-r--r--sinksh/syntax_modules/sink_list.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp
index e4c4837..b002438 100644
--- a/sinksh/syntax_modules/sink_list.cpp
+++ b/sinksh/syntax_modules/sink_list.cpp
@@ -96,9 +96,6 @@ bool list(const QStringList &args_, State &state)
96 } 96 }
97 97
98 auto options = SyntaxTree::parseOptions(args_); 98 auto options = SyntaxTree::parseOptions(args_);
99
100 auto type = options.positionalArguments.isEmpty() ? QString{} : options.positionalArguments.first();
101
102 bool asLine = true; 99 bool asLine = true;
103 100
104 Sink::Query query; 101 Sink::Query query;
@@ -107,30 +104,14 @@ bool list(const QStringList &args_, State &state)
107 state.printError(QObject::tr("Options: $type [--resource $resource] [--compact] [--filter $property=$value] [--showall|--show $property]")); 104 state.printError(QObject::tr("Options: $type [--resource $resource] [--compact] [--filter $property=$value] [--showall|--show $property]"));
108 return false; 105 return false;
109 } 106 }
110 if (options.options.contains("resource")) { 107
111 for (const auto &f : options.options.value("resource")) {
112 query.resourceFilter(f.toLatin1());
113 }
114 }
115 if (options.options.contains("filter")) {
116 for (const auto &f : options.options.value("filter")) {
117 auto filter = f.split("=");
118 const auto property = filter.value(0).toLatin1();
119 query.filter(property, Sink::PropertyParser::parse(type.toLatin1(), property, filter.value(1)));
120 }
121 }
122 if (options.options.contains("id")) {
123 for (const auto &f : options.options.value("id")) {
124 query.filter(f.toUtf8());
125 }
126 }
127 auto compact = options.options.contains("compact"); 108 auto compact = options.options.contains("compact");
128 if (!options.options.contains("showall")) { 109 if (!options.options.contains("showall")) {
129 if (options.options.contains("show")) { 110 if (options.options.contains("show")) {
130 auto list = options.options.value("show"); 111 auto list = options.options.value("show");
131 std::transform(list.constBegin(), list.constEnd(), std::back_inserter(query.requestedProperties), [] (const QString &s) { return s.toLatin1(); }); 112 std::transform(list.constBegin(), list.constEnd(), std::back_inserter(query.requestedProperties), [] (const QString &s) { return s.toLatin1(); });
132 } else { 113 } else {
133 query.requestedProperties = SinkshUtils::requestedProperties(type); 114 query.requestedProperties = SinkshUtils::requestedProperties(query.type());
134 } 115 }
135 } else { 116 } else {
136 asLine = false; 117 asLine = false;
@@ -139,7 +120,7 @@ bool list(const QStringList &args_, State &state)
139 QByteArrayList toPrint; 120 QByteArrayList toPrint;
140 QStringList tableLine; 121 QStringList tableLine;
141 122
142 for (const auto &o : SinkshUtils::getStore(type).read(query)) { 123 for (const auto &o : SinkshUtils::getStore(query.type()).read(query)) {
143 if (tableLine.isEmpty()) { 124 if (tableLine.isEmpty()) {
144 tableLine << QObject::tr("Resource") << QObject::tr("Identifier"); 125 tableLine << QObject::tr("Resource") << QObject::tr("Identifier");
145 if (query.requestedProperties.isEmpty()) { 126 if (query.requestedProperties.isEmpty()) {