Skip to content

Commit dcf97f3

Browse files
lightningd/log: fixes plugin help
Signed-off-by: Nishant Bansal <[email protected]>
1 parent 2f64283 commit dcf97f3

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

cli/lightning-cli.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ static size_t human_readable(const char *buffer, const jsmntok_t *t, char term)
4949
i++;
5050
continue;
5151
}
52+
} else if (buffer[i] == '|') {
53+
fputc('\n', stdout);
54+
i++;
55+
continue;
5256
}
5357
fputc(buffer[i], stdout);
5458
}
@@ -85,8 +89,8 @@ static size_t flat_json(const char *prefix,
8589
switch (t->type) {
8690
case JSMN_PRIMITIVE:
8791
case JSMN_STRING:
88-
printf("%s=%.*s\n",
89-
prefix, t->end - t->start, buffer + t->start);
92+
printf("%s=", prefix);
93+
human_readable(buffer, t, '\n');
9094
return 1;
9195
case JSMN_ARRAY:
9296
n = 1;
@@ -197,8 +201,8 @@ static void human_help(char *buffer, const jsmntok_t *result)
197201
for (i = 0; i < tal_count(help); i++) {
198202
const jsmntok_t *command;
199203
command = json_get_member(buffer, help[i], "command");
200-
printf("%.*s\n\n",
201-
command->end - command->start, buffer + command->start);
204+
human_readable(buffer, command, '\n');
205+
printf("\n");
202206
}
203207
tal_free(help);
204208

contrib/pyln-client/pyln/client/plugin.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def get_usage(self):
8484
args.append("[%s]" % arg)
8585

8686
if self.description is not None:
87-
args.append("\n%s" % self.description)
87+
doc = inspect.getdoc(self.func)
88+
doc = re.sub('\n+', ' | ', doc)
89+
args.append(" | %s" % doc)
8890

8991
return " ".join(args)
9092

@@ -938,16 +940,6 @@ def _getmanifest(self, **kwargs) -> JSONType:
938940
'after': method.after})
939941
continue
940942

941-
doc = inspect.getdoc(method.func)
942-
if not doc:
943-
self.log(
944-
'RPC method \'{}\' does not have a docstring.'.format(
945-
method.name
946-
)
947-
)
948-
doc = "Undocumented RPC method from a plugin."
949-
doc = re.sub('\n+', ' ', doc)
950-
951943
# For compatibility with lightningd prior to 24.08, we must
952944
# provide a description. Ignored by 24.08 onwards,
953945
description = method.description

0 commit comments

Comments
 (0)