diff --git a/man/lkt.template b/man/lkt.template index 78cd742759035d9d67e3fa571c9a996ed67fa6be..b11343d4c2de761c01472b593c80325f15dadd49 100644 --- a/man/lkt.template +++ b/man/lkt.template @@ -121,7 +121,7 @@ Replace the queue with the content of a playlist. Keep the playling state .PD 0 .TP .PD -\fBsearch database\fP <query> +\fBsearch [database]\fP <query> Search and prints the kara that correspond to the query in the database .TP \fBsearch plt\fP <plt-name> <query> @@ -252,17 +252,12 @@ For the following types of queries, the type part is optional: \fIid\fP, queries are recognise as such when reding the regex part: .IP \[bu] 2 -\fI'type'\fP: If the regex is all in upper case, it will be treated as a -\fItype\fP of kara, if the \fItype\fP is invalid \fBlkt\fP will return an -error. This means that you can't do any other queries with only upper case -characters. -.IP \[bu] \fI'id'\fP: If the regex is a number, it will be treated as an \fIid\fP. This means that you can't search the database with a unique number as a \fIquery\fP but it should not be a problem. .IP \[bu] -\fI'lang'\fP and \fI'category'\fP: If the regex is in lower case and matches a -\fIlang\fP or a \fIcategory\fP, the type will be infered. +\fI'type'\fP, \fI'lang'\fP and \fI'category'\fP: If the regex matches a +\fItype\fP or a \fIlang\fP or a \fIcategory\fP, the type will be infered. .IP \[bu] \fI'query'\fP: If no other type is infered and no type is recognised (the query does not begin by \fIauthor\fP, \fIplaylist\fP), then all the regex is diff --git a/src/main/lkt.c b/src/main/lkt.c index caa4f808cf6d12f382af5e349ad66168d796ab53..ccb02b2ae7f3c800883e8e6d6393323efa0c646b 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -1109,7 +1109,7 @@ static struct cmd_opt options_search[] = { { .name = "plt", .call = search_plt__ }, { .name = "count", .call = search_count__ }, { .name = "queue", .call = search_queue__ }, - CMD_OPT_NULL, + CMD_OPT_DEFAULT(search_db__), }; static struct cmd_opt options_admin[] = { @@ -1187,20 +1187,15 @@ parse_args(args_t *args, int argc, const char **argv) for (i = 1; i < argc && i < 3; ++i) { len = strcspn(argv[i], "=:"); - if (STR_NMATCH("host", argv[i], len)) { - args->host = (argv[i] + len + 1); - ++got; - } - - else if (STR_NMATCH("port", argv[i], len)) { - args->port = (argv[i] + len + 1); - ++got; - } - - else if (STR_NMATCH("pwd", argv[i], len)) { - args->pwd = (argv[i] + len + 1); - ++got; - } +#define __get_args(name) \ +if (STR_NMATCH(#name, argv[i], len)) { \ + args->name = (argv[i] + len + 1); \ + ++got; \ +} + __get_args(host); + __get_args(port); + __get_args(pwd); +#undef __get_args } args->argv = &argv[got + 1];