magda revised this gist 1 week ago. Go to revision
1 file changed, 1 insertion, 1 deletion
pretty_print.d
| @@ -6,7 +6,7 @@ private void print_help(const ref GetoptResult help_info) | |||
| 6 | 6 | ||
| 7 | 7 | writefln("Usage: %s [OPTION...]", Runtime.args[0].baseName); | |
| 8 | 8 | writeln(); | |
| 9 | - | writeln("Convert D .lst coverage files to LCOV format."); | |
| 9 | + | writeln("Program description"); | |
| 10 | 10 | writeln(); | |
| 11 | 11 | writeln("Options:"); | |
| 12 | 12 | ||
magda revised this gist 1 week ago. Go to revision
1 file changed, 21 insertions
pretty_print.d(file created)
| @@ -0,0 +1,21 @@ | |||
| 1 | + | private void print_help(const ref GetoptResult help_info) | |
| 2 | + | { | |
| 3 | + | import core.runtime; | |
| 4 | + | import std.path : baseName; | |
| 5 | + | import std.algorithm : map, maxElement; | |
| 6 | + | ||
| 7 | + | writefln("Usage: %s [OPTION...]", Runtime.args[0].baseName); | |
| 8 | + | writeln(); | |
| 9 | + | writeln("Convert D .lst coverage files to LCOV format."); | |
| 10 | + | writeln(); | |
| 11 | + | writeln("Options:"); | |
| 12 | + | ||
| 13 | + | string[] flags; | |
| 14 | + | foreach (opt; help_info.options) | |
| 15 | + | flags ~= opt.optShort ~ (opt.optShort.length ? ", " : " ") ~ opt.optLong; | |
| 16 | + | ||
| 17 | + | size_t width = flags.map!(f => f.length).maxElement + 1; | |
| 18 | + | ||
| 19 | + | foreach (i, opt; help_info.options) | |
| 20 | + | writefln(" %-*s %s", width, flags[i], opt.help); | |
| 21 | + | } | |