[libvirt] [PATCH 06/41] remote: stop trying to print help as giant blocks of text

Andrea Bolognani abologna at redhat.com
Mon Jul 29 12:42:47 UTC 2019


On Mon, 2019-07-29 at 10:51 +0100, Daniel P. Berrangé wrote:
> On Fri, Jul 26, 2019 at 02:02:18PM +0200, Andrea Bolognani wrote:
> > On Tue, 2019-07-23 at 17:02 +0100, Daniel P. Berrangé wrote:
> > > +    fprintf(stderr, "    %s:\n", _("TLS"));
> > > +    fprintf(stderr, "      %s: %s\n",
> > > +            _("CA certificate"),
> > > +            privileged ? LIBVIRT_CACERT : "$HOME/.pki/libvirt/cacert.pem");
> > > +    fprintf(stderr, "      %s: %s\n",
> > > +            _("Server certificate"),
> > > +            privileged ? LIBVIRT_SERVERCERT : "$HOME/.pki/libvirt/servercert.pem");
> > > +    fprintf(stderr, "      %s: %s\n",
> > > +            _("Server private key"),
> > > +            privileged ? LIBVIRT_SERVERKEY : "$HOME/.pki/libvirt/serverkey.pem");
> > > +    fprintf(stderr, "\n");
> > 
> > I think the above would work better if you used
> > 
> >   "      %-18s  %s\n"
> > 
> > as the format string, which would result in
> > 
> >   TLS:
> >     CA certificate      $HOME/.pki/libvirt/cacert.pem
> >     Server certificate  $HOME/.pki/libvirt/servercert.pem
> >     Server private key  $HOME/.pki/libvirt/serverkey.pem
> > 
> > instead of
> > 
> >   TLS:
> >     CA certificate: $HOME/.pki/libvirt/cacert.pem
> >     Server certificate: $HOME/.pki/libvirt/servercert.pem
> >     Server private key: $HOME/.pki/libvirt/serverkey.pem
> 
> You're only thinking about this from POV of english text. When this
> is translated into other languages, all bets are off for such
> alignment, as translated text could easily be longer than 18 characters
> and I don't fancy guessing the max field width to cope with arbitrary
> languages.

Right, I was tricked by the fact that you use "%-22s" earlier in the
same function, but of course that's appropriate because you're
printing the option names and those are not subject to i18n...

We should move the vshTable API inside libvirt so that we can do this
kind of thing easily! (Only partially kidding.)

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list