Added "searchcount" command, a case-insensitive "count"
The `count` command isn't case-insensitive. This adds `searchcount` which is a case-insensitive version of `count`.
This commit is contained in:

committed by
Max Kellermann

parent
8b1ff3f005
commit
6adff85fd6
@@ -189,6 +189,7 @@ static constexpr struct command commands[] = {
|
||||
{ "search", PERMISSION_READ, 1, -1, handle_search },
|
||||
{ "searchadd", PERMISSION_ADD, 1, -1, handle_searchadd },
|
||||
{ "searchaddpl", PERMISSION_CONTROL, 2, -1, handle_searchaddpl },
|
||||
{ "searchcount", PERMISSION_READ, 1, -1, handle_searchcount },
|
||||
#endif
|
||||
{ "seek", PERMISSION_PLAYER, 2, 2, handle_seek },
|
||||
{ "seekcur", PERMISSION_PLAYER, 1, 1, handle_seekcur },
|
||||
|
@@ -231,8 +231,8 @@ handle_searchaddpl(Client &client, Request args, Response &)
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_count(Client &client, Request args, Response &r)
|
||||
static CommandResult
|
||||
handle_count_internal(Client &client, Request args, Response &r, bool fold_case)
|
||||
{
|
||||
TagType group = TAG_NUM_OF_ITEM_TYPES;
|
||||
if (args.size() >= 2 && StringIsEqual(args[args.size() - 2], "group")) {
|
||||
@@ -251,7 +251,7 @@ handle_count(Client &client, Request args, Response &r)
|
||||
SongFilter filter;
|
||||
if (!args.empty()) {
|
||||
try {
|
||||
filter.Parse(args, false);
|
||||
filter.Parse(args, fold_case);
|
||||
} catch (...) {
|
||||
r.Error(ACK_ERROR_ARG,
|
||||
GetFullMessage(std::current_exception()).c_str());
|
||||
@@ -265,6 +265,18 @@ handle_count(Client &client, Request args, Response &r)
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_count(Client &client, Request args, Response &r)
|
||||
{
|
||||
return handle_count_internal(client, args, r, false);
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_searchcount(Client &client, Request args, Response &r)
|
||||
{
|
||||
return handle_count_internal(client, args, r, true);
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_listall(Client &client, Request args, Response &r)
|
||||
{
|
||||
|
@@ -47,6 +47,9 @@ handle_searchadd(Client &client, Request request, Response &response);
|
||||
CommandResult
|
||||
handle_searchaddpl(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_searchcount(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_count(Client &client, Request request, Response &response);
|
||||
|
||||
|
Reference in New Issue
Block a user