Browse Source

lightning-cli: clean up human_help() function.

Final arg is always 'false'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pull/2938/head
Rusty Russell 6 years ago
parent
commit
7b1088a235
  1. 11
      cli/lightning-cli.c

11
cli/lightning-cli.c

@ -152,7 +152,8 @@ same_category:
buffer); buffer);
} }
static void human_help(char *buffer, const jsmntok_t *result, bool has_command) { static void human_help(char *buffer, const jsmntok_t *result)
{
unsigned int i; unsigned int i;
/* `curr` is used as a temporary token */ /* `curr` is used as a temporary token */
const jsmntok_t *curr; const jsmntok_t *curr;
@ -182,8 +183,7 @@ static void human_help(char *buffer, const jsmntok_t *result, bool has_command)
category = json_get_member(buffer, help[i], "category"); category = json_get_member(buffer, help[i], "category");
if (category && !json_tok_streq(buffer, category, prev_cat)) { if (category && !json_tok_streq(buffer, category, prev_cat)) {
prev_cat = json_strdup(help, buffer, category); prev_cat = json_strdup(help, buffer, category);
if (!has_command) printf("=== %s ===\n\n", prev_cat);
printf("=== %s ===\n\n", prev_cat);
} }
command = json_get_member(buffer, help[i], "command"); command = json_get_member(buffer, help[i], "command");
@ -195,8 +195,7 @@ static void human_help(char *buffer, const jsmntok_t *result, bool has_command)
} }
tal_free(help); tal_free(help);
if (!has_command) printf("---\nrun `lightning-cli help <command>` for more information on a specific command\n");
printf("---\nrun `lightning-cli help <command>` for more information on a specific command\n");
} }
enum format { enum format {
@ -595,7 +594,7 @@ int main(int argc, char *argv[])
// if we have specific help command // if we have specific help command
if (format == HUMAN) if (format == HUMAN)
if (streq(method, "help") && command == NULL) if (streq(method, "help") && command == NULL)
human_help(resp, result, false); human_help(resp, result);
else else
human_readable(resp, result, '\n'); human_readable(resp, result, '\n');
else if (format == RAW) else if (format == RAW)

Loading…
Cancel
Save