command/Database: add "sort" parameter to "find" and "search"

Implement the second part of https://bugs.musicpd.org/view.php?id=3990
This commit is contained in:
Max Kellermann
2017-02-08 09:22:15 +01:00
parent 1e0a60e73d
commit 3850716522
7 changed files with 178 additions and 9 deletions

View File

@@ -67,6 +67,16 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
} else
window.SetAll();
TagType sort = TAG_NUM_OF_ITEM_TYPES;
if (args.size >= 2 && StringIsEqual(args[args.size - 2], "sort")) {
sort = tag_name_parse_i(args.back());
if (sort == TAG_NUM_OF_ITEM_TYPES)
throw ProtocolError(ACK_ERROR_ARG, "Unknown sort tag");
args.pop_back();
args.pop_back();
}
SongFilter filter;
if (!filter.Parse(args, fold_case)) {
r.Error(ACK_ERROR_ARG, "incorrect arguments");
@@ -77,6 +87,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
db_selection_print(r, client.partition,
selection, true, false,
sort,
window.start, window.end);
return CommandResult::OK;
}