[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Allow more than one line in option help text
From: |
Christian Franke |
Subject: |
[PATCH] Allow more than one line in option help text |
Date: |
Fri, 23 Jan 2009 20:27:44 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 |
This small patch allows '\n' in option help texts, for example:
static const struct grub_arg_option options[] = {
{"very-complex", 'c', 0,
"sorry, but this very complex option requires more\n"
"than one line to explain properly.", 0, 0},
...
};
grub> complex -h
...
-c, --very-complex sorry, but this very complex option requires more
. than one line to explain properly.
I need it for a new module :-)
Christian
2009-01-23 Christian Franke <address@hidden>
* normal/arg.c (grub_arg_show_help): Add indentation if '\n' appears
in option help text.
diff --git a/normal/arg.c b/normal/arg.c
index 602f7ea..42cf44e 100644
--- a/normal/arg.c
+++ b/normal/arg.c
@@ -156,10 +156,21 @@ grub_arg_show_help (grub_command_t cmd)
}
}
- while (spacing-- > 0)
- grub_putchar (' ');
+ const char * doc = opt->doc;
+ for (;;)
+ {
+ while (spacing-- > 0)
+ grub_putchar (' ');
+
+ const char * nl = grub_strchr (doc, '\n');
+ if (! nl)
+ break;
- grub_printf ("%s\n", opt->doc);
+ while (doc <= nl)
+ grub_putchar (*doc++);
+ spacing = 4 + 20;
+ }
+ grub_printf ("%s\n", doc);
switch (opt->shortarg)
{
- [PATCH] Allow more than one line in option help text,
Christian Franke <=