charon-cmd: support multi-line help text for each option in usage
This commit is contained in:
@@ -199,7 +199,7 @@ static void segv_handler(int signal)
|
|||||||
*/
|
*/
|
||||||
static void usage(FILE *out, char *msg, char *binary)
|
static void usage(FILE *out, char *msg, char *binary)
|
||||||
{
|
{
|
||||||
int i, pre, post, padto = 0, spacing = 2;
|
int i, line, pre, post, padto = 0, spacing = 2;
|
||||||
|
|
||||||
for (i = 0; i < CMD_OPT_COUNT; i++)
|
for (i = 0; i < CMD_OPT_COUNT; i++)
|
||||||
{
|
{
|
||||||
@@ -235,6 +235,14 @@ static void usage(FILE *out, char *msg, char *binary)
|
|||||||
pre, cmd_options[i].arg, post,
|
pre, cmd_options[i].arg, post,
|
||||||
padto - strlen(cmd_options[i].name) - strlen(cmd_options[i].arg), "",
|
padto - strlen(cmd_options[i].name) - strlen(cmd_options[i].arg), "",
|
||||||
cmd_options[i].desc);
|
cmd_options[i].desc);
|
||||||
|
for (line = 0; line < countof(cmd_options[i].lines); line++)
|
||||||
|
{
|
||||||
|
if (cmd_options[i].lines[line])
|
||||||
|
{
|
||||||
|
fprintf(out, "%-*s %s\n",
|
||||||
|
padto, "", cmd_options[i].lines[line]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,10 @@ struct cmd_option_t {
|
|||||||
int has_arg;
|
int has_arg;
|
||||||
/** decription of argument */
|
/** decription of argument */
|
||||||
const char *arg;
|
const char *arg;
|
||||||
/** description to option */
|
/** short description to option */
|
||||||
const char *desc;
|
const char *desc;
|
||||||
|
/** additional description lines */
|
||||||
|
const char *lines[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user