shell: add getopt library support
This functionality is is enabled by setting CONFIG_SHELL_GETOPT. It is not active by default. User can call following functions inside command handlers: - shell_getopt - getopt function based on freebsd implementation - shell_getopt_status_get - returns getopt status Beware when getopt functionality is enabled shell will not parse command handler to look for "-h" or "--help" options and print help message automatically. Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
parent
74ebf5dba2
commit
7e46765153
6 changed files with 124 additions and 1 deletions
|
@ -533,6 +533,10 @@ static int exec_cmd(const struct shell *shell, size_t argc, const char **argv,
|
|||
}
|
||||
|
||||
if (!ret_val) {
|
||||
#if CONFIG_SHELL_GETOPT
|
||||
z_shell_getopt_init(&shell->ctx->getopt_state);
|
||||
#endif
|
||||
|
||||
z_flag_cmd_ctx_set(shell, true);
|
||||
/* Unlock thread mutex in case command would like to borrow
|
||||
* shell context to other thread to avoid mutex deadlock.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue