shell: commands help unification

1. Changed return value of function: shell_cmd_precheck from bool to
int. Now it returns:
  0       when argument count is correct and help print is not requested
  1       when help was requested and printed
  -EINVAL on wrong arguments count
This change simply shell_cmd_precheck usege in command handlers.

2. Unified all commands in shell_cmd.c file.

3. Fixed a bug where help was not printed on wrong argument count.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2018-10-18 14:33:24 +02:00 committed by Carles Cufí
commit a88d5d7e4f
3 changed files with 187 additions and 131 deletions

View file

@ -572,12 +572,14 @@ int shell_prompt_change(const struct shell *shell, char *prompt);
* @param[in] opt Pointer to the optional option array.
* @param[in] opt_len Option array size.
*
* @return True if check passed, false otherwise or help was requested.
* @return 0 if check passed
* @return 1 if help was requested
* @return -EINVAL if wrong argument count
*/
bool shell_cmd_precheck(const struct shell *shell,
bool arg_cnt_ok,
const struct shell_getopt_option *opt,
size_t opt_len);
int shell_cmd_precheck(const struct shell *shell,
bool arg_cnt_ok,
const struct shell_getopt_option *opt,
size_t opt_len);
/**
* @internal @brief This function shall not be used directly, it is required by