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:
Jakub Rzeszutko 2021-01-15 14:04:21 +01:00 committed by Anas Nashif
commit 7e46765153
6 changed files with 124 additions and 1 deletions

View file

@ -109,6 +109,12 @@ config SHELL_VT100_COLORS
help
If enabled VT100 colors are used in shell (e.g. print errors in red).
config SHELL_GETOPT
bool "Enable getopt support"
select GETOPT
help
Enables getopt support in the shell.
config SHELL_METAKEYS
bool "Enable metakeys"
default y if !SHELL_MINIMAL