shell: add select command

The "select" command has been implemented, which allows user to
narrow down the command tree.

This implementation differs from the "select" command available
in the legacy shell. In a new implementation, if the selected
command has a handler and if the user has not entered the
registered subcommand, the shell will call the handler of selected
command and pass the text as arguments.

This may be useful, for example, if someone wants to use the
shell as an interface to a modem that supports AT commands.
Instead of each time you write e.g:
	at at+command1
	at at+command2
	at at+command3
user can execute following commands:
	select at
	at+command1
	at+command2
	at+command3

where:
at - root command for passing at commands to the modem
at+commandX - at command passed to the modem.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2019-05-16 11:02:53 +02:00 committed by Carles Cufí
commit b633e431a4
8 changed files with 227 additions and 96 deletions

View file

@ -140,6 +140,13 @@ config SHELL_CMDS_RESIZE
must be called to ensure correct text display on the terminal screen.
The resize command can be turned off to save code memory (~0,5k).
config SHELL_CMDS_SELECT
bool "Enable select command"
depends on SHELL_CMDS
help
This option enables select command. It can be used to set new root
command. Exit to main command tree is with alt+r.
config SHELL_LOG_BACKEND
bool
default y if LOG