-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
shell: Refactor command getters #24219
shell: Refactor command getters #24219
Conversation
@@ -252,7 +252,7 @@ static bool tab_prepare(const struct shell *shell, | |||
/* root command completion */ | |||
if ((*argc == 0) || ((space == 0) && (*argc == 1))) { | |||
*complete_arg_idx = SHELL_CMD_ROOT_LVL; | |||
*cmd = NULL; | |||
*cmd = shell->ctx->selected_cmd; |
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.
selected_cmd is null when no selection so it can be used to setup parent.
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
|
||
if (!found) { | ||
if (!is_empty_cmd(candidate) && is_candidate) { | ||
*longest = Z_MAX(strlen(candidate->syntax), *longest); |
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.
Z_MAX
is "evaluate once" version of MAX
722a8b4
to
f31209f
Compare
@nordic-krch : Nice simplifaction! :) |
084fe15
to
f31209f
Compare
beware that more is coming 😄 #24329 |
@nordic-krch could you please rebase? |
a067c46
to
2ffab63
Compare
Refactor and simplified fetching commands from the tree of commands. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
@carlescufi done |
@carlescufi can you merge? |
Refactor and simplified fetching commands from the tree
of commands.
Main change is changing
shell_cmd_get
to simply returnstruct shell_static_entry *
. Previously it was getting as argument command level and pointer to command. Those arguments were redundant since command level was only used to distinguish between root command and others. Now, it is simpler as function gets pointer to parent command (null to get one of the root commands). Returns requested entry.Many algorithms now looks simpler, there is also 250bytes less code (not much but still something).
Note, this refactoring is a start point for further shell improvements around
select
command.Signed-off-by: Krzysztof Chruscinski krzysztof.chruscinski@nordicsemi.no