doc: shell: update example usage of shell_cmd_precheck function

Updated example usage of shell_cmd_precheck according to new API.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2018-10-18 15:51:26 +02:00 committed by Carles Cufí
commit 917dd83e8b

View file

@ -228,8 +228,10 @@ checks for valid arguments count.
*
* Each of these actions can be deactivated in Kconfig.
*/
if (!shell_cmd_precheck(shell, (argc <= 2), NULL, 0) {
return 0;
int err = shell_cmd_precheck(shell, (argc <= 2), NULL, 0);
if (err) {
return err;
}
shell_fprintf(shell, SHELL_NORMAL,
@ -271,6 +273,7 @@ in command handler.
static int cmd_with_options(const struct shell *shell, size_t argc,
char **argv)
{
int err;
/* Dummy options showing options usage */
static const struct shell_getopt_option opt[] = {
SHELL_OPT(
@ -288,9 +291,10 @@ in command handler.
/* If command will be called with -h or --help option
* all declared options will be listed in the help message
*/
if (!shell_cmd_precheck(shell, (argc <= 2), opt,
sizeof(opt)/sizeof(opt[1]))) {
return 0;
err = shell_cmd_precheck(shell, (argc <= 2), opt,
sizeof(opt)/sizeof(opt[1]));
if (err) {
return err;
}
/* checking if command was called with test option */