charon-cmd: Changed formatting of optional arguments in usage information
authorTobias Brunner <tobias@strongswan.org>
Tue, 7 May 2013 13:05:12 +0000 (15:05 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 May 2013 10:30:36 +0000 (12:30 +0200)
Optional arguments have to be specified with = after the option.

src/charon-cmd/charon-cmd.c

index a77794a..f898fd6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2012 Tobias Brunner
+ * Copyright (C) 2006-2013 Tobias Brunner
  * Copyright (C) 2005-2013 Martin Willi
  * Copyright (C) 2006 Daniel Roethlisberger
  * Copyright (C) 2005 Jan Hutter
@@ -199,7 +199,8 @@ static void segv_handler(int signal)
  */
 static void usage(FILE *out, char *msg, char *binary)
 {
-       int i, line, pre, post, padto = 0, spacing = 2;
+       char *pre, *post;
+       int i, line, padto = 0, spacing = 2;
 
        for (i = 0; i < CMD_OPT_COUNT; i++)
        {
@@ -218,19 +219,20 @@ static void usage(FILE *out, char *msg, char *binary)
                switch (cmd_options[i].has_arg)
                {
                        case required_argument:
-                               pre = '<';
-                               post = '>';
+                               pre = " <";
+                               post = ">";
                                break;
                        case optional_argument:
-                               pre = '[';
-                               post = ']';
+                               pre = "[=";
+                               post = "]";
                                break;
                        case no_argument:
                        default:
-                               pre = post = ' ';
+                               pre = "  ";
+                               post = " ";
                                break;
                }
-               fprintf(out, "  --%s %c%s%c %-*s%s\n",
+               fprintf(out, "  --%s%s%s%s %-*s%s\n",
                        cmd_options[i].name,
                        pre, cmd_options[i].arg, post,
                        padto - strlen(cmd_options[i].name) - strlen(cmd_options[i].arg), "",