MCPcopy Create free account
hub / github.com/ElementsProject/lightning / human_help

Function human_help

cli/lightning-cli.c:176–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176static void human_help(char *buffer, const jsmntok_t *result)
177{
178 unsigned int i;
179 /* `curr` is used as a temporary token */
180 const jsmntok_t *curr;
181 /* Contains all commands objects, which have the following structure :
182 * {
183 * "command": "The command name and usage"
184 * }
185 */
186 const jsmntok_t * help_array = json_get_member(buffer, result, "help");
187 const jsmntok_t **help = tal_arr(NULL, const jsmntok_t *,
188 help_array->size);
189
190 /* Populate an array for easy sorting with asort */
191 json_for_each_arr(i, curr, help_array)
192 help[i] = curr;
193
194 asort(help, tal_count(help), compare_help, buffer);
195
196 for (i = 0; i < tal_count(help); i++) {
197 const jsmntok_t *command;
198 command = json_get_member(buffer, help[i], "command");
199 human_readable(buffer, command, '\n');
200 printf("\n");
201 }
202 tal_free(help);
203
204 printf("---\nrun `lightning-cli help <command>` for more information on a specific command\n");
205}
206
207enum format {
208 JSON,

Callers 1

mainFunction · 0.85

Calls 3

json_get_memberFunction · 0.85
human_readableFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected