aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-04-26 23:15:31 +0200
committerMax Kellermann <max@duempel.org>2014-04-27 22:27:43 +0200
commitbc2a1160b824c3ccf98ed658ef0d60c0f3d5bf5c (patch)
tree6daa38432619e8e0713504de3972af73007164df /src/command
parent75542e8f5d615c31282e6e8562bb1b71222af999 (diff)
downloadmpd-bc2a1160b824c3ccf98ed658ef0d60c0f3d5bf5c.tar.gz
mpd-bc2a1160b824c3ccf98ed658ef0d60c0f3d5bf5c.tar.xz
mpd-bc2a1160b824c3ccf98ed658ef0d60c0f3d5bf5c.zip
db/Count: implement grouping
Diffstat (limited to 'src/command')
-rw-r--r--src/command/DatabaseCommands.cxx18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx
index 0f23dc959..f41c89c45 100644
--- a/src/command/DatabaseCommands.cxx
+++ b/src/command/DatabaseCommands.cxx
@@ -153,14 +153,28 @@ handle_count(Client &client, int argc, char *argv[])
{
ConstBuffer<const char *> args(argv + 1, argc - 1);
+ TagType group = TAG_NUM_OF_ITEM_TYPES;
+ if (args.size >= 2 && strcmp(args[args.size - 2], "group") == 0) {
+ const char *s = args[args.size - 1];
+ group = tag_name_parse_i(s);
+ if (group == TAG_NUM_OF_ITEM_TYPES) {
+ command_error(client, ACK_ERROR_ARG,
+ "Unknown tag type: %s", s);
+ return CommandResult::ERROR;
+ }
+
+ args.pop_back();
+ args.pop_back();
+ }
+
SongFilter filter;
- if (!filter.Parse(args, false)) {
+ if (!args.IsEmpty() && !filter.Parse(args, false)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return CommandResult::ERROR;
}
Error error;
- return PrintSongCount(client, "", &filter, error)
+ return PrintSongCount(client, "", &filter, group, error)
? CommandResult::OK
: print_error(client, error);
}