[PATCH] cosmetic: improve command list display

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Following from the Frank Jullien's patch, here is the same cosmetic correction
when the list of commands is printed (the problem was that the commands for
gpio_* were too long for the %10s alignment)

Signed-off-by: Carlo Caione <carlo.caione@xxxxxxxxx>
---
 commands/help.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/commands/help.c b/commands/help.c
index 72b0bef..a12d9c3 100644
--- a/commands/help.c
+++ b/commands/help.c
@@ -28,12 +28,17 @@
 static int do_help(int argc, char *argv[])
 {
 	struct command *cmdtp;
+	int max_length = 0;
 
 	if (argc == 1) {	/* show list of commands */
+		for_each_command(cmdtp)
+			if(strlen(cmdtp->name) > max_length)
+				max_length = strlen(cmdtp->name);
+
 		for_each_command(cmdtp) {
 			if (!cmdtp->usage)
 				continue;
-			printf("%10s - %s\n", cmdtp->name, cmdtp->usage);
+			printf("%*s - %s\n", max_length, cmdtp->name, cmdtp->usage);
 		}
 		return 0;
 	}
-- 
1.7.12.3


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux