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:
parent
147122e77f
commit
917dd83e8b
1 changed files with 9 additions and 5 deletions
|
@ -228,8 +228,10 @@ checks for valid arguments count.
|
||||||
*
|
*
|
||||||
* Each of these actions can be deactivated in Kconfig.
|
* Each of these actions can be deactivated in Kconfig.
|
||||||
*/
|
*/
|
||||||
if (!shell_cmd_precheck(shell, (argc <= 2), NULL, 0) {
|
int err = shell_cmd_precheck(shell, (argc <= 2), NULL, 0);
|
||||||
return 0;
|
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL,
|
shell_fprintf(shell, SHELL_NORMAL,
|
||||||
|
@ -271,6 +273,7 @@ in command handler.
|
||||||
static int cmd_with_options(const struct shell *shell, size_t argc,
|
static int cmd_with_options(const struct shell *shell, size_t argc,
|
||||||
char **argv)
|
char **argv)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
/* Dummy options showing options usage */
|
/* Dummy options showing options usage */
|
||||||
static const struct shell_getopt_option opt[] = {
|
static const struct shell_getopt_option opt[] = {
|
||||||
SHELL_OPT(
|
SHELL_OPT(
|
||||||
|
@ -288,9 +291,10 @@ in command handler.
|
||||||
/* If command will be called with -h or --help option
|
/* If command will be called with -h or --help option
|
||||||
* all declared options will be listed in the help message
|
* all declared options will be listed in the help message
|
||||||
*/
|
*/
|
||||||
if (!shell_cmd_precheck(shell, (argc <= 2), opt,
|
err = shell_cmd_precheck(shell, (argc <= 2), opt,
|
||||||
sizeof(opt)/sizeof(opt[1]))) {
|
sizeof(opt)/sizeof(opt[1]));
|
||||||
return 0;
|
if (err) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* checking if command was called with test option */
|
/* checking if command was called with test option */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue