From: Peter Krempa Date: Tue, 12 Nov 2013 14:11:55 +0000 (+0100) Subject: virsh-volume: Unify alignment of vol-list output columns X-Git-Tag: v1.2.0-rc1~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6fdcb88b96d70981fff896a1b1a5034be47439b;p=thirdparty%2Flibvirt.git 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 --- diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 0a66a6c7ac..d85ae92154 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -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");