WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl: wrap help output if command name is too long

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl: wrap help output if command name is too long
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 30 Sep 2011 10:59:53 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 30 Sep 2011 03:05:15 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1317376782 -3600
# Node ID d546d9dfb9d6f81c97e66a5ef5c6c93aaedbfb06
# Parent  0b5c45508431906a947ef578e40ebac1ef59d79f
xl: wrap help output if command name is too long

Without this in the "xl help" line for pci-list-assignable-devices the command
name merges with the first word of the help. Since the bash completion support
parses "xl help" this leads to "pci-list-assignable-devicesList" being
presented as an option instead of the correct command name.

We also need to filter out lines which start with more than one space in the
bash completion support to stop "List" appearing as a possible command name
after the change to wrap it.

Doesn't address the fact thatsome help text overflows 80 columns.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 0b5c45508431 -r d546d9dfb9d6 tools/libxl/bash-completion
--- a/tools/libxl/bash-completion       Fri Sep 30 10:53:05 2011 +0100
+++ b/tools/libxl/bash-completion       Fri Sep 30 10:59:42 2011 +0100
@@ -11,7 +11,7 @@ _xl()
        xl=xl
 
        if [[ $COMP_CWORD == 1 ]] ; then
-               opts=`${xl} help 2>/dev/null | sed '1,4d' | awk '{print $1}' | 
sed 's/$/ ,/g'` && COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+               opts=`${xl} help 2>/dev/null | sed '1,4d' | awk '/^ [^ ]/ 
{print $1}' | sed 's/$/ ,/g'` && COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
                return 0
        fi
 
diff -r 0b5c45508431 -r d546d9dfb9d6 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Sep 30 10:53:05 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri Sep 30 10:59:42 2011 +0100
@@ -1791,9 +1791,12 @@ void help(const char *command)
     if (!command || !strcmp(command, "help")) {
         printf("Usage xl [-vN] <subcommand> [args]\n\n");
         printf("xl full list of subcommands:\n\n");
-        for (i = 0; i < cmdtable_len; i++)
-            printf(" %-20s%s\n",
-                   cmd_table[i].cmd_name, cmd_table[i].cmd_desc);
+        for (i = 0; i < cmdtable_len; i++) {
+            printf(" %-19s ", cmd_table[i].cmd_name);
+            if (strlen(cmd_table[i].cmd_name) > 19)
+                printf("\n %-19s ", "");
+            printf("%s\n", cmd_table[i].cmd_desc);
+        }
     } else {
         cmd = cmdtable_lookup(command);
         if (cmd) {

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] xl: wrap help output if command name is too long, Ian Campbell <=