mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Carlo Caione <carlo.caione@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH] cosmetic: improve command list display
Date: Fri, 12 Oct 2012 00:14:29 +0200	[thread overview]
Message-ID: <1349993669-27959-1-git-send-email-carlo.caione@gmail.com> (raw)

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@gmail.com>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2012-10-11 22:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-11 22:14 Carlo Caione [this message]
2012-10-12  8:54 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349993669-27959-1-git-send-email-carlo.caione@gmail.com \
    --to=carlo.caione@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox