diff options
author | Mike Frysinger <vapier@gentoo.org> | 2007-09-25 22:57:32 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2007-09-25 22:57:32 +0000 |
commit | 7d9acd968f7a0537b258f23edaca2c85a0774b47 (patch) | |
tree | 61061475c4c61c589c131dcf3462ac76bedceafd /src | |
parent | 8ce7911f106bbfa97f8f23d033b3aa22c45c5665 (diff) |
display whether an option takes an argument in the usage output
Diffstat (limited to 'src')
-rw-r--r-- | src/_usage.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/_usage.c b/src/_usage.c index be41e313..141a15a0 100644 --- a/src/_usage.c +++ b/src/_usage.c @@ -9,15 +9,20 @@ static void usage (int exit_status) { + const char * const has_arg[] = { "", "<arg>", "[arg]" }; int i; printf ("Usage: " APPLET " [options] "); #ifdef extraopts printf (extraopts); #endif printf ("\n\nOptions: [" getoptstring "]\n"); - for (i = 0; longopts[i].name; ++i) - printf (" -%c, --%-15s %s\n", longopts[i].val, longopts[i].name, - longopts_help[i]); + for (i = 0; longopts[i].name; ++i) { + int len = printf (" -%c, --%s %s", longopts[i].val, longopts[i].name, + has_arg[longopts[i].has_arg]); + while (++len < 25) + printf (" "); + puts (longopts_help[i]); + } exit (exit_status); } |