- conn->state = S_PROCESS;
-
- svec_init(&argv);
- svec_parse_words(&argv, s);
- svec_terminate(&argv);
-
- if (argv.n == 0) {
- unixctl_command_reply(conn, 400, "missing command name in request");
+ conn->request_id = json_clone(request->id);
+
+ params = json_array(request->params);
+ command = shash_find_data(&commands, request->method);
+ if (!command) {
+ error = xasprintf("\"%s\" is not a valid command", request->method);
+ } else if (params->n < command->min_args) {
+ error = xasprintf("\"%s\" command requires at least %d arguments",
+ request->method, command->min_args);
+ } else if (params->n > command->max_args) {
+ error = xasprintf("\"%s\" command takes at most %d arguments",
+ request->method, command->max_args);