-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subsys: shell rework #9362
subsys: shell rework #9362
Conversation
@carlescufi FYI |
Codecov Report
@@ Coverage Diff @@
## master #9362 +/- ##
==========================================
- Coverage 52.94% 52.18% -0.77%
==========================================
Files 214 212 -2
Lines 26163 25924 -239
Branches 5639 5570 -69
==========================================
- Hits 13853 13528 -325
- Misses 10037 10133 +96
+ Partials 2273 2263 -10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. I like the dynamic command sample. Some minor comments from me.
u32_t dynamic_lvl; | ||
u32_t compiled_lvl; | ||
u32_t i; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excess empty line, please also check between functions.
subsys/logging/log_cmds.c
Outdated
for (i = 0; i < modules_cnt; i++) { | ||
p_tmp_name = log_source_name_get(CONFIG_LOG_DOMAIN_ID, i); | ||
|
||
if (strncmp(p_tmp_name, p_name, 64) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you name this 64?
static void cmd_log_backends_list(const struct shell *shell, | ||
size_t argc, char **argv) | ||
{ | ||
int backend_count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsigned or size_t
cedc5e8
to
0d14a8b
Compare
0d14a8b
to
6ccb523
Compare
0d14a8b
to
8b6bc35
Compare
92e1ad3
to
4277bca
Compare
6af21fe
to
fa1b52d
Compare
fa1b52d
to
edec325
Compare
f39563d
to
4a381e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
subsys/shell/Kconfig
Outdated
@@ -33,3 +33,89 @@ config CONSOLE_SHELL_MAX_CMD_QUEUED | |||
source "subsys/shell/modules/Kconfig" | |||
|
|||
endif | |||
|
|||
config SHELL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tried this with make menuconfig
and the shell support looks really bad as all the config options are in the "root". The Kconfig seems to be missing menu "Shell support"
or similar command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I will update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jukkar : done
New shell implementation is on the way. For now old one and all references are kept to be gradually replaced by new shell. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
New shell support features like: - multi-instance - command tree - static and dynamic commands - multiline - help print function - smart tab (autocompletion) - meta-keys - history, wildcards etc. - generic transport (initially, uart present) Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no> Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no> Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
Ported shell sample to use new shell. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added function for peeking into previous item in the list. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Extending shell with terminal-like history feature. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added optional shell commands: - clear - for clearing terminal - history - commands history - resize - terminal resize - shell - controling echo and colors Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no> Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Initial logger backend support added to shell. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added commands for getting current status and controlling which log messages are forwared to available backends. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Library will be used by new shell implementation. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no> Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
4a381e8
to
9e43bbd
Compare
Extended shell to support wildcard characters: * and ? and expand commands accordingly. Increased default stack size. Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no> Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
9e43bbd
to
9b8682c
Compare
Fix merge error introduced in: ba01a39 (as part of zephyrproject-rtos#9362) which deleted the native_posix backend for the logger. Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Me and @nordic-krch have reworked Zephyr shell Task 8872.
New one has a lot of useful features that were missing in the old one.
We have changed commands concept.
On one command level all commands must be the same type: static or dynamic.
An example usage of dynamic commands concept is described here:
https://devzone.nordicsemi.com/b/blog/posts/new-command-line-interface-part-1
Commands execution
Each command or subcommand on each level can either have or not have a handler. Shell executes the handler that is found deepest in the command tree and further subcommands (without a handler) are passed as arguments. Characters within parentheses are treated as one argument. Each command or subcommand without a handler can be treated as an argument, or it can still have a subcommand with a handler and there is no problem for the user to execute it.
It is recommended to use subcommands over options. Options apply mainly in the case when an argument with '-' or "--" is requested.
Commands help
Every user-defined command, subcommand, or option can have its own help description. The help for commands and subcommands can be created with respective macros: SHELL_CMD_REGISTER, SHELL_CMD. In addition, you can define options for commands or subcommands using the macro SHELL_OPT. By default, each and every command or subcommand has these two options implemented: "-h" and "--help".
In order to add help functionality to a command or subcommand, you must call the help function shell_help_print inside of a command handler.
New features:
Multi-instance - you can have independent shells on different transmission mediums
Multiline commands - Shell will correctly print and allow to edit commands longer than 1 line.
Integration with Log module - you can read logs on the shell screen, filter them dynamically (activate logs only for needed modules), suspend or resume. At the same time you can type, edit or execute a command.
Smart completion with the Tab key. One can prompt and partially/fully complete commands or its subcommands.
Commands history - Executed commands can be listed by
history
command or recalled with up / down arrows.Built-in commands - Shell related commands already implemented and available for the user:
clear
- clears the screenhistory
- prints recently called commandsresize
- command shall be called each time terminal width has changed. It will ensure correct text formatting (currently it is only working with UART flow control on)shell colors
- switch on / off colored syntaxshell echo
- switch on / off shell echoshell backspace_mode
- allows to adjust backspace escape code during runtime.shell stats
- gives an information about lost (not printed) logsEasy command edition with buttons: Tab/Backspace/Delete/Arrows/Home/End
Meta Keys:
Wildcards support for:
*
and?
Kconfig configuration to optimize resources usage.