mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] cosmetic: improve command list display
@ 2012-10-11 22:14 Carlo Caione
  2012-10-12  8:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Carlo Caione @ 2012-10-11 22:14 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cosmetic: improve command list display
  2012-10-11 22:14 [PATCH] cosmetic: improve command list display Carlo Caione
@ 2012-10-12  8:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2012-10-12  8:54 UTC (permalink / raw)
  To: Carlo Caione; +Cc: barebox

On Fri, Oct 12, 2012 at 12:14:29AM +0200, Carlo Caione wrote:
> 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>

Applied, thanks.

Other than my reply to Franck I think here it makes sense as we have two
columns to print and thus really need alignment.

Sascha

> ---
>  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
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-12  8:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 22:14 [PATCH] cosmetic: improve command list display Carlo Caione
2012-10-12  8:54 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox