-
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 execution to enable raw arguments #24329
Conversation
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. |
subsys/shell/shell_utils.c
Outdated
@@ -12,7 +12,7 @@ extern const struct shell_cmd_entry __shell_root_cmds_end[0]; | |||
|
|||
static inline const struct shell_cmd_entry *shell_root_cmd_get(u32_t id) | |||
{ | |||
return &__shell_root_cmds_start[id]; | |||
return &__shell_root_cmds_start[id]; |
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.
I believe we can benefit from this extra space in the future ;)
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.
ok, will remove it. For now. This PR already have enough of improvements :)
a565d2a
to
fe18b04
Compare
@stig-bjorlykke this should work with AT commands. once AT command is selected, it will pass whole command content to the handler. You have to define at command like the one in PR description:
|
* that only mandatory arguments shall be parsed and remaining command string is | ||
* passed as a raw string. | ||
*/ | ||
#define SHELL_OPT_ARG_RAW (0xFE) |
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.
I think that information about SHELL_OPT_ARG_RAW
and SHELL_ARG_MAX
values shall be added in KCONFIG help for SHELL_ARGC_MAX
. Or maybe we could limit SHELL_ARGC_MAX
in KCONFIG ?
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.
i think there is no relation between those 2. This is limit for optional arguments, there are also mandatory arguments so in theory SHELL_ARGC_MAX
could be more than 255, even more than 510. Of course, this is rather unrealistic values so i don't want to put any relation there.
include/shell/shell.h
Outdated
#define SHELL_OPT_ARG_RAW (0xFE) | ||
|
||
/** @brief Flag indicating maximum number of arguments. */ | ||
#define SHELL_ARG_MAX (0xFD) |
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.
This name is quite similar to SHELL_ARGC_MAX
in Kconfig.
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.
renamed to SHELL_OPT_ARG_MAX
.
1cf3158
to
2bbe34e
Compare
@jakub-uC ping. Merge window is closing soon. |
@nordic-krch please rebase |
Added special flag that can be used to indicate that optional arguments are passed without any parsing (e.g. quotation marks removal). Modified execute command to parse command line buffer argument by argument. After this change it is possible to forward whole command to command handler (using select). Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2bbe34e
to
06b64ac
Compare
Added test for commands with SHELL_OPT_ARG_RAW flag set. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added special flag that can be used to indicate that optional arguments are passed without any parsing (e.g. quotation marks removal). Modified execute command to parse command line buffer argument by argument.
After this change it is possible to forward whole command to command handler (using select).
It is now possible to specify command like:
SHELL_CMD_ARG_REGISTER(python, NULL, "Python", cmd_python, 1, SHELL_OPT_ARG_RAW);
Then call
and whole content from the prompt will be passed directly to the handler without splitting into arguments, removing quotation marks, etc.
Fixes #24216.
Fixes #23907.
Signed-off-by: Krzysztof Chruscinski krzysztof.chruscinski@nordicsemi.no