virsh-volume: Unify alignment of vol-list output columns

Add an extra space before the first column as we have when listing
domains.

Previous output:

$ virsh vol-list glusterpool
Name                 Path
-----------------------------------------
asdf                 gluster://gluster-node-1/gv0/asdf
c                    gluster://gluster-node-1/gv0/c
cd                   gluster://gluster-node-1/gv0/cd

$ virsh vol-list glusterpool --details
Name  Path                               Type     Capacity  Allocation
----------------------------------------------------------------------
asdf  gluster://gluster-node-1/gv0/asdf  unknown    0.00 B      0.00 B
c     gluster://gluster-node-1/gv0/c     unknown   16.00 B     16.00 B
cd    gluster://gluster-node-1/gv0/cd    unknown    0.00 B      0.00 B

New output:

$ virsh vol-list glusterpool
 Name                 Path
------------------------------------------------------------------------------
 asdf                 gluster://gluster-node-1/gv0/asdf
 c                    gluster://gluster-node-1/gv0/c
 cd                   gluster://gluster-node-1/gv0/cd

$ virsh vol-list glusterpool --details
 Name  Path                               Type     Capacity  Allocation
------------------------------------------------------------------------
 asdf  gluster://gluster-node-1/gv0/asdf  unknown    0.00 B      0.00 B
 c     gluster://gluster-node-1/gv0/c     unknown   16.00 B     16.00 B
 cd    gluster://gluster-node-1/gv0/cd    unknown    0.00 B      0.00 B
This commit is contained in:
Peter Krempa 2013-11-12 15:11:55 +01:00
parent 7f2b173feb
commit d6fdcb88b9

View File

@ -1450,10 +1450,11 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Output basic info then return if --details option not selected */ /* Output basic info then return if --details option not selected */
if (!details) { if (!details) {
/* The old output format */ /* The old output format */
vshPrintExtra(ctl, "%-20s %-40s\n", _("Name"), _("Path")); vshPrintExtra(ctl, " %-20s %-40s\n", _("Name"), _("Path"));
vshPrintExtra(ctl, "-----------------------------------------\n"); vshPrintExtra(ctl, "---------------------------------------"
"---------------------------------------\n");
for (i = 0; i < list->nvols; i++) { for (i = 0; i < list->nvols; i++) {
vshPrint(ctl, "%-20s %-40s\n", virStorageVolGetName(list->vols[i]), vshPrint(ctl, " %-20s %-40s\n", virStorageVolGetName(list->vols[i]),
volInfoTexts[i].path); volInfoTexts[i].path);
} }
@ -1503,7 +1504,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Create the output template */ /* Create the output template */
ret = virAsprintf(&outputStr, ret = virAsprintf(&outputStr,
"%%-%lus %%-%lus %%-%lus %%%lus %%%lus\n", " %%-%lus %%-%lus %%-%lus %%%lus %%%lus\n",
(unsigned long) nameStrLength, (unsigned long) nameStrLength,
(unsigned long) pathStrLength, (unsigned long) pathStrLength,
(unsigned long) typeStrLength, (unsigned long) typeStrLength,
@ -1519,7 +1520,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
("Capacity"), _("Allocation")); ("Capacity"), _("Allocation"));
for (i = nameStrLength + pathStrLength + typeStrLength for (i = nameStrLength + pathStrLength + typeStrLength
+ capStrLength + allocStrLength + capStrLength + allocStrLength
+ 8; i > 0; i--) + 10; i > 0; i--)
vshPrintExtra(ctl, "-"); vshPrintExtra(ctl, "-");
vshPrintExtra(ctl, "\n"); vshPrintExtra(ctl, "\n");