summaryrefslogtreecommitdiff
path: root/src/command/DatabaseCommands.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-12-18 21:50:14 +0100
committerMax Kellermann <max@musicpd.org>2017-12-18 21:50:14 +0100
commit7a55ab6acc307d1023c3f1b87f2c0b28ab6c37fb (patch)
tree049ddc392f5033ddb255dbd54d3689ed4dc24942 /src/command/DatabaseCommands.cxx
parent6246d36fe6503e6bed3bca6aa5ca783c6188d76f (diff)
db/DatabasePrint: support descending sort
Diffstat (limited to 'src/command/DatabaseCommands.cxx')
-rw-r--r--src/command/DatabaseCommands.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx
index aad7d3a4c..a6e56dfc6 100644
--- a/src/command/DatabaseCommands.cxx
+++ b/src/command/DatabaseCommands.cxx
@@ -68,8 +68,15 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
window.SetAll();
TagType sort = TAG_NUM_OF_ITEM_TYPES;
+ bool descending = false;
if (args.size >= 2 && StringIsEqual(args[args.size - 2], "sort")) {
- sort = tag_name_parse_i(args.back());
+ const char *s = args.back();
+ if (*s == '-') {
+ descending = true;
+ ++s;
+ }
+
+ sort = tag_name_parse_i(s);
if (sort == TAG_NUM_OF_ITEM_TYPES)
throw ProtocolError(ACK_ERROR_ARG, "Unknown sort tag");
@@ -87,7 +94,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
db_selection_print(r, client.GetPartition(),
selection, true, false,
- sort,
+ sort, descending,
window.start, window.end);
return CommandResult::OK;
}