]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Implement CMD_FLAG_HIDDEN to actually hide doveadm commands from usage
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 4 Apr 2022 13:42:07 +0000 (16:42 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 8 Apr 2022 05:48:26 +0000 (05:48 +0000)
src/doveadm/client-connection-http.c
src/doveadm/doveadm.c

index 92075efdfe6645d5930949b4529717ae709d3be7..27aa5a01d7623b3548c4d5d6c0cb1759c167a2fd 100644 (file)
@@ -773,14 +773,18 @@ doveadm_http_server_send_api_v1(struct client_request_http *req)
        const struct doveadm_cmd_param *par;
        unsigned int i, k;
        string_t *tmp;
-       bool sent;
+       bool sent, first_cmd = TRUE;
 
        tmp = str_new(req->pool, 8);
 
        o_stream_nsend_str(output,"[\n");
        for (i = 0; i < array_count(&doveadm_cmds_ver2); i++) {
                cmd = array_idx(&doveadm_cmds_ver2, i);
-               if (i > 0)
+               if ((cmd->flags & CMD_FLAG_HIDDEN) != 0)
+                       continue;
+               if (first_cmd)
+                       first_cmd = FALSE;
+               else
                        o_stream_nsend_str(output, ",\n");
                o_stream_nsend_str(output, "\t{\"command\":\"");
                json_append_escaped(tmp, cmd->name);
index a9a147c55fb96d93ad519387353850be226b3368..5ffc45f5e60356d39e9d0e9dc31fe26d00cc66d9 100644 (file)
@@ -121,8 +121,10 @@ usage_prefix(const char *prefix)
                fprintf(stderr, "%s ", prefix);
        fprintf(stderr, "<command> [<args>]\n");
 
-       array_foreach(&doveadm_cmds_ver2, cmd2)
-               str_printfa(str, "%s\t%s\n", cmd2->name, cmd2->usage);
+       array_foreach(&doveadm_cmds_ver2, cmd2) {
+               if ((cmd2->flags & CMD_FLAG_HIDDEN) == 0)
+                       str_printfa(str, "%s\t%s\n", cmd2->name, cmd2->usage);
+       }
 
        doveadm_usage_compress_lines(stderr, str_c(str), prefix);