__fish_print_help: Make formatting more man-like

1. Leave the indentation
2. Leave the "NAME" header - without the first line would be
unindented
3. Leave the "SYNOPSIS" header

We use $MANPAGER here, so it should be formatted like a manpage.

The alternative is to write special docs for this use-case, which
would be shorter and point towards the full man page.

Fixes #10625
This commit is contained in:
Fabian Boehm 2024-10-03 11:19:30 +02:00
parent 07bc54f406
commit 0fea1dae8c

View file

@ -92,9 +92,7 @@ function __fish_print_help --description "Print help message for the specified f
# Remove man's bolding # Remove man's bolding
set -l name (string replace -ra '(.)'\b'.' '$1' -- $line) set -l name (string replace -ra '(.)'\b'.' '$1' -- $line)
# We start after we have the name # We start after we have the name
contains -- $name NAME; and set have_name 1; and continue contains -- $name NAME; and set have_name 1
# We ignore the SYNOPSIS header
contains -- $name SYNOPSIS; and continue
# Everything after COPYRIGHT is useless # Everything after COPYRIGHT is useless
contains -- $name COPYRIGHT; and break contains -- $name COPYRIGHT; and break
@ -123,8 +121,7 @@ function __fish_print_help --description "Print help message for the specified f
end end
end end
end end
end | string replace -ra '^ ' '' | end | begin
begin
set -l pager (__fish_anypager --with-manpager) set -l pager (__fish_anypager --with-manpager)
and isatty stdout and isatty stdout
or set pager cat # cannot use a builtin here or set pager cat # cannot use a builtin here