Options with multiple parameters are now correctly shown at debug message
This commit is contained in:
parent
0b6a5d19cb
commit
cc49a3c674
|
@ -154,6 +154,7 @@ done:
|
||||||
int options_command_line(int argc, char *argv[], int (*handle_options)(int short_option, int argi, char *argv[]))
|
int options_command_line(int argc, char *argv[], int (*handle_options)(int short_option, int argi, char *argv[]))
|
||||||
{
|
{
|
||||||
option_t *option;
|
option_t *option;
|
||||||
|
char params[256];
|
||||||
int argi, i;
|
int argi, i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -167,9 +168,12 @@ int options_command_line(int argc, char *argv[], int (*handle_options)(int short
|
||||||
/* -x */
|
/* -x */
|
||||||
for (option = option_head; option; option = option->next) {
|
for (option = option_head; option; option = option->next) {
|
||||||
if (argv[argi][1] == option->short_option) {
|
if (argv[argi][1] == option->short_option) {
|
||||||
if (option->parameter_count && argi + option->parameter_count < argc)
|
if (option->parameter_count && argi + option->parameter_count < argc) {
|
||||||
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s' ('--%s'), parameter '%s'\n", argv[argi], option->long_option, argv[argi + 1]);
|
params[0] = '\0';
|
||||||
else
|
for (i = 0; i < option->parameter_count; i++)
|
||||||
|
sprintf(strchr(params, '\0'), " '%s'", argv[argi + 1 + i]);
|
||||||
|
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s' ('--%s'), parameter%s\n", argv[argi], option->long_option, params);
|
||||||
|
} else
|
||||||
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s' ('--%s')\n", argv[argi], option->long_option);
|
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s' ('--%s')\n", argv[argi], option->long_option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -178,9 +182,12 @@ int options_command_line(int argc, char *argv[], int (*handle_options)(int short
|
||||||
/* --xxxxxx */
|
/* --xxxxxx */
|
||||||
for (option = option_head; option; option = option->next) {
|
for (option = option_head; option; option = option->next) {
|
||||||
if (!strcmp(argv[argi] + 2, option->long_option)) {
|
if (!strcmp(argv[argi] + 2, option->long_option)) {
|
||||||
if (option->parameter_count && argi + option->parameter_count < argc)
|
if (option->parameter_count && argi + option->parameter_count < argc) {
|
||||||
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s', parameter '%s'\n", argv[argi], argv[argi + 1]);
|
params[0] = '\0';
|
||||||
else
|
for (i = 0; i < option->parameter_count; i++)
|
||||||
|
sprintf(strchr(params, '\0'), " '%s'", argv[argi + 1 + i]);
|
||||||
|
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s', parameter%s\n", argv[argi], params);
|
||||||
|
} else
|
||||||
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s'\n", argv[argi]);
|
PDEBUG(DOPTIONS, DEBUG_INFO, "Command line option '%s'\n", argv[argi]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue