shell: Refactor command getters

Refactor and simplified fetching commands from the tree
of commands.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2020-04-08 15:42:06 +02:00 committed by Carles Cufí
commit 53b5bae41b
7 changed files with 108 additions and 195 deletions

View file

@ -43,25 +43,18 @@ char shell_make_argv(size_t *argc, char **argv, char *cmd, uint8_t max_argc);
*/
void shell_pattern_remove(char *buff, u16_t *buff_len, const char *pattern);
/* @brief Function shall be used to search commands.
/** @brief Get subcommand with given index from the root.
*
* It moves the pointer entry to command of static command structure. If the
* command cannot be found, the function will set entry to NULL.
* @param parent Parent entry. Null to get root command from index.
* @param idx Command index.
* @param dloc Location used to write dynamic entry.
*
* @param shell Shell instance.
* @param command Pointer to command which will be processed (no matter
* the root command).
* @param lvl Level of the requested command.
* @param idx Index of the requested command.
* @param entry Pointer which points to subcommand[idx] after function
* execution.
* @param st_entry Pointer to the structure where dynamic entry data can
* be stored.
* @return Fetched command or null if command with that index does not exist.
*/
void shell_cmd_get(const struct shell *shell,
const struct shell_cmd_entry *command, size_t lvl,
size_t idx, const struct shell_static_entry **entry,
struct shell_static_entry *d_entry);
const struct shell_static_entry *shell_cmd_get(
const struct shell_static_entry *parent,
size_t idx,
struct shell_static_entry *dloc);
/* @internal @brief Function returns pointer to a shell's subcommands array