]> git.ipfire.org Git - thirdparty/git.git/commit - parse-options.c
short help: allow multi-line opthelp
authorJunio C Hamano <gitster@pobox.com>
Tue, 18 Jul 2023 22:54:04 +0000 (15:54 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Jul 2023 23:30:06 +0000 (16:30 -0700)
commit448abbba63471153df6ba520a5621595557ce3c8
tree49e2f80c40ec5cdf9163d6f6387122fe139676f2
parentfb7d80edcae482f4fa5d4be0227dc3054734e5f3
short help: allow multi-line opthelp

When "-h" triggers the short-help in a command that implements its
option parsing using the parse-options API, the option help text is
shown with a single fprintf() as a long line.  When the text is
multi-line, the second and subsequent lines are not left padded,
that breaks the alignment across options.

Borrowing the idea from the advice API where its hint strings are
shown with (localized) "hint:" prefix, let's internally split the
(localized) help text into lines, and showing the first line, pad
the remaining lines to align.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
t/helper/test-parse-options.c
t/t0040-parse-options.sh