[libvirt] Re: [PATCH] virsh: Enhance list command to ease creation of shell scripts
Nicolas Sebrecht
nsebrecht at piing.fr
Wed Feb 22 08:46:22 UTC 2012
The 21/02/12, Eric Blake wrote:
> On 02/21/2012 09:05 AM, Peter Krempa wrote:
> > @@ -950,77 +986,125 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
> > }
> > }
> >
> > - if (desc) {
> > - vshPrintExtra(ctl, "%-5s %-30s %-10s %s\n", _("Id"), _("Name"), _("State"), _("Title"));
> > - vshPrintExtra(ctl, "-----------------------------------------------------------\n");
> > - } else {
> > - vshPrintExtra(ctl, " %-5s %-30s %s\n", _("Id"), _("Name"), _("State"));
> > - vshPrintExtra(ctl, "----------------------------------------------------\n");
>
> The old style printed a variable-length ---- line, depending on whether
> title was in the mix...
>
> > + /* print table header in legacy mode */
> > + if (optTable) {
> > + vshPrintExtra(ctl, " %-5s %-30s %-10s",
> > + _("Id"), _("Name"), _("State"));
> > + if (optTitle)
> > + vshPrintExtra(ctl, "%-20s", _("Title"));
> > +
> > + vshPrintExtra(ctl, "\n"
> > + "-----------------------------------------------------------\n");
>
> but your new version prints a fixed-width ---- line as if title were
> always present. Not necessarily a show-stopper, but worth thinking about.
BTW, I find that the %-ns format is not easy to parse from scripts. It
would be easier with raw variable values and a dedicated separator like
a tabulation.
Human and scripts expectations are so... different! :-)
--
Nicolas Sebrecht
More information about the libvir-list
mailing list