OSDN Git Service

client: prettify help table
authorLucas De Marchi <lucas.demarchi@intel.com>
Fri, 21 Jun 2013 14:17:35 +0000 (11:17 -0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 24 Jun 2013 08:12:59 +0000 (11:12 +0300)
cmd + options have a maximum length of 25. Align the description
after this value. In order not to reach 80 chars so easily change the
first \t to 2 spaces, like is done in udev, kmod, systemd, etc.

client/main.c

index ff2afc6..0dd1510 100644 (file)
@@ -1184,9 +1184,10 @@ static void rl_handler(char *input)
 
        for (i = 0; cmd_table[i].cmd; i++) {
                if (cmd_table[i].desc)
-                       printf("\t%s %s\t%s\n", cmd_table[i].cmd,
-                                               cmd_table[i].arg ? : "    ",
-                                               cmd_table[i].desc);
+                       printf("  %s %-*s %s\n", cmd_table[i].cmd,
+                                       (int)(25 - strlen(cmd_table[i].cmd)),
+                                       cmd_table[i].arg ? : "",
+                                       cmd_table[i].desc ? : "");
        }
 
 done: