mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +01:00
Rpc: sort help output by command name
This commit is contained in:
parent
e99335eefb
commit
f65eecee27
1 changed files with 10 additions and 0 deletions
|
@ -13,11 +13,13 @@
|
|||
* that point, the `json_connection` becomes the owner (or it's simply freed).
|
||||
*/
|
||||
/* eg: { "jsonrpc":"2.0", "method" : "dev-echo", "params" : [ "hello", "Arabella!" ], "id" : "1" } */
|
||||
#include "ccan/config.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <bitcoin/address.h>
|
||||
#include <bitcoin/base58.h>
|
||||
#include <bitcoin/script.h>
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/asort/asort.h>
|
||||
#include <ccan/err/err.h>
|
||||
#include <ccan/io/io.h>
|
||||
#include <ccan/str/hex/hex.h>
|
||||
|
@ -346,6 +348,12 @@ static const struct json_command *find_command(struct json_command **commands,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int compare_commands_name(struct json_command *const *a,
|
||||
struct json_command *const *b, void *unused)
|
||||
{
|
||||
return strcmp((*a)->name, (*b)->name);
|
||||
}
|
||||
|
||||
static struct command_result *json_help(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *obj UNNEEDED,
|
||||
|
@ -372,6 +380,8 @@ static struct command_result *json_help(struct command *cmd,
|
|||
} else
|
||||
one_cmd = NULL;
|
||||
|
||||
asort(commands, tal_count(commands), compare_commands_name, NULL);
|
||||
|
||||
response = json_stream_success(cmd);
|
||||
json_object_start(response, NULL);
|
||||
json_array_start(response, "help");
|
||||
|
|
Loading…
Add table
Reference in a new issue