-
Notifications
You must be signed in to change notification settings - Fork 913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyln-client+cli: Fix formatting issues for plugin description in lightning-cli help #8022
base: master
Are you sure you want to change the base?
pyln-client+cli: Fix formatting issues for plugin description in lightning-cli help #8022
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, I love it! Just need to make it specific to help output only, and fix commits a bit.
args.append("\n%s" % self.description) | ||
doc = inspect.getdoc(self.func) | ||
doc = re.sub('\n+', ' | ', doc) | ||
args.append(" | %s" % doc) | ||
|
||
return " ".join(args) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the next commit?
Also, the Changelog line for the first commit is unnecessary: this isn't a user-visible change!
cli/lightning-cli.c
Outdated
printf("%.*s\n\n", | ||
command->end - command->start, buffer + command->start); | ||
human_readable(buffer, command, '\n'); | ||
printf("\n"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
human_readable() is used in other contexts, and this will break it. In particular, the summary plugin.
I think this replacement needs to occur inline:
static void replace_char(char *buf, size_t len, char old, char new)
{
char *p = buf, *end = buf + len;
while ((p = memchr(p, old, end - p)) != NULL)
*p = new;
}
Then simply call replace_char(buffer + command->start, command->end - command_start, '|', '\n')
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; however, this part:
else if (buffer[i] == '|') {
fputc('\n', stdout);
continue;
}
is necessary for formatting the help output in cases of commands like lightning-cli help funds
or lightning-cli help funds -H
for external plugins such as funds
.
The `doc` variable was being initialised and processed but not used anywhere. Changelog-None Signed-off-by: Nishant Bansal <[email protected]>
Changelog-Changed: Replaced \n with | as the line separator in the plugin to enhance the readability of lightning-cli help. Signed-off-by: Nishant Bansal <[email protected]>
Changelog-Changed: Updated the `lightning-cli help` output by replacing '\n' with '|' as a line separator, enhancing readability and consistency. Signed-off-by: Nishant Bansal <[email protected]>
90d9502
to
b1fe851
Compare
Fixes: #8020
Improved formatting of plugin descriptions displayed in the
lightning-cli help
output: Previously, the descriptions contained unnecessary\n
characters when shown as a single line, which affected readability.Proposed Solution: Replace
\n
with|
as the line separator when output is displayed in a single line, for better clarity and consistency.Removed unused variables and related code from
pyln-client
: For example, thedoc
variable inpyln/client/plugin.py
was declared but never utilized, and related code was cleaned up to improve maintainability.Important
24.11 FREEZE NOVEMBER 7TH: Non-bugfix PRs not ready by this date will wait for 25.02.
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked: