]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-volume: Unify alignment of vol-list output columns
authorPeter Krempa <pkrempa@redhat.com>
Tue, 12 Nov 2013 14:11:55 +0000 (15:11 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Nov 2013 16:01:25 +0000 (17:01 +0100)
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

tools/virsh-volume.c

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