Skip to content
Permalink
Browse files

native_posix: cmdline: Hint user about wrong options

Be a bit more friendly to users, by providing some hints
about possible reasons why a command line option was not
understood.
Also describe in the help message that which options are
avaliable depends on what has been selected in this build.

Fixes: #15046

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
  • Loading branch information...
aescolar authored and nashif committed Mar 30, 2019
1 parent cc15b9c commit 149cc7fda156a6403292b59629e669bcb885ebad
Showing with 12 additions and 2 deletions.
  1. +10 −2 boards/posix/native_posix/cmdline.c
  2. +2 −0 boards/posix/native_posix/cmdline_common.c
@@ -95,6 +95,15 @@ void native_add_testargs_option(void)
native_add_command_line_opts(testargs_options);
}

static void print_invalid_opt_error(char *argv)
{
posix_print_error_and_exit("Incorrect option '%s'. Did you misspell it?"
" Is that feature supported in this build?"
"\n",
argv);

}

/**
* Handle possible command line arguments.
*
@@ -122,8 +131,7 @@ void native_handle_cmd_line(int argc, char *argv[])

if (!cmd_parse_one_arg(argv[i], args_struct)) {
cmd_print_switches_help(args_struct);
posix_print_error_and_exit("Incorrect option '%s'\n",
argv[i]);
print_invalid_opt_error(argv[i]);
}
}
}
@@ -350,6 +350,8 @@ void cmd_print_long_help(struct args_struct_t args_struct[])
count++;
}
fprintf(stdout, "\n");
fprintf(stdout, "Note that which options are available depends on the "
"enabled features/drivers\n\n");
}

/*

0 comments on commit 149cc7f

Please sign in to comment.
You can’t perform that action at this time.