Subject: bug#44248: Indentation of --help and --version

From: Pádraig Brady <[email-masked]>
Date: Thu, 29 Oct 2020 21:50:12 +0000

On 29/10/2020 21:25, Roland Illig wrote:
> On 28.10.2020 21:55, Bernhard Voelker wrote:
>> We have so many utils that it may be worth writing some utility functions
>> to automatically do the alignment.  Usually, that part of the usage output
>> has 3 columns:
>> a) the short option (if any),
>> b) the long option (if any),
>> c) the description (maybe multiline).
> 
> I completely agree. This would be nice to have, both for users and for
> translators.
> 
>> E.g. for ls.c:usage:
>>      usage_param("-a", "--all", _("do not ignore entries starting with ."));
>>      ...
>>      usage_param(NULL, "--dereference-command-line-symlink-to-dir",
>>                        _("follow each command line symbolic link\n"
>>                          "that points to a directory"));
>>     usage_param_help();
>>     usage_param_version();
>> and a final:
>>     usage_param_finish();
> 
> This code adds a bit of redundancy.  The relation between -a and --all
> is already expressed when setting up the getopt_long.  It is repeated here.
> 
> Ideally there would be a single definition from which both the
> getopt_long options and the --help string are derived.  Some prior art
> can be found at https://golang.org/pkg/flag/.

Maybe, though I don't want to over engineer anything here.
We're not going to be adding new options that often.

> I don't like the hard line break in the option description.  The line
> breaks should be computed based on the terminal size or a fixed line
> width.  It's not possible to predict the screen column in which in the
> option description will start, since that depends on the names of the
> other options.  Therefore, the option descriptions should be wrapped as
> necessary.  See fold(1).

Yes agreed.

Spacing or alignment should not need consideration for translators.
That includes line feeds.

We probably should provide some context to translators also like:
/* TRANSLATORS: --dereference-command-line-symlink-to-dir option  */

cheers,
Pádraig