-
Notifications
You must be signed in to change notification settings - Fork 11
Improvements for cli behaviour #76
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
Conversation
* add option to ignore man pages by flag CMDLINE_INCLUDE_MAN=<bool> * add true and false commands and tests for available operators and, or, semicolon * add retcode tests * cleaning comments
* rename define CMDLINE_INCLUDE_MAN to MBED_CMDLINE_INCLUDE_MAN * remove underscore macro - use it always * add warning trace if max arguments reached * clean up some compiler warnings
* allow to store also int values for variables * fixes alt+left behaviour * add "?" variable for last retcode * add function for request screen size
|
#77 need to to be fixed first to get this PR green |
| } | ||
| // // alias test | ||
| // extern void replace_alias(const char *str, const char *old_str, const char *new_str); | ||
| // TEST(cli, cmd_alias_1) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/Test.cpp
Outdated
| ARRAY_CMP("\r\nvariables:\r\n" | ||
| "PS1='/>'\r\n" | ||
| "?=-1\r\n" | ||
| "\r\x1b[2K/> \x1b[1D", buf); |
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.
replace with macros
test/Test.cpp
Outdated
| ARRAY_CMP("\r\nvariables:\r\n" | ||
| "PS1='/>'\r\n" | ||
| "?=0\r\n" | ||
| "\r\x1b[2K/> \x1b[1D", buf); |
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.
replace with macros
| #define TRACE_GROUP "cmdL" | ||
|
|
||
| #ifndef MBED_CMDLINE_BOOT_MESSAGE | ||
| #define MBED_CMDLINE_BOOT_MESSAGE "ARM Ltd\r\n" |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| #endif | ||
| //include manuals or not (save memory a little when not include) | ||
| #define INCLUDE_MAN | ||
| #ifndef MBED_CMDLINE_INCLUDE_MAN |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
YifeiZuo01
left a comment
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.
test/Test.cpp
Outdated
| ARRAY_CMP("\r\nalias:\r\n" | ||
| "_ 'alias'\r\n" | ||
| "_ 'alias foo'\r\n" | ||
| "\r\x1b[2K/> \x1b[1D", buf); |
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.
replace with macros
test/Test.cpp
Outdated
| "foo 'bar'\r\n" | ||
| "_ 'alias'\r\n" | ||
| "_ 'alias foo bar'\r\n" | ||
| "\r\x1b[2K/> \x1b[1D", buf); |
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.
replace with macros
YifeiZuo01
left a comment
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.
|
ok for me. |
|
If the limit is the line going past the screen it sounds more like an issue of the terminal application than the cli library. The only limitations it has are the serial input buffer size (was for example 768 bytes in mbed-os-cliapp at some point), mbed-client-cli input buffer size (2000 bytes by default), and how fast the mcu can move the bytes out of one to the other. For example on a K64F with those buffer sizes pasting in a string of up to around 1500 characters at once worked fine. (Though admittedly that may have been with echo off.. It's been a while.) |
source/ns_cmdline.c
Outdated
| } | ||
| return NULL; | ||
| } | ||
| static const char* strrevchr(const char* from, const char* to, const char c) |
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.
What exactly is this function meant to do? Find the last occurrence of a character in a string?
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.
exactly - between two pointers
source/ns_cmdline.c
Outdated
| } | ||
| while((from > to) && (*from == c)) { | ||
| from--; | ||
| } |
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.
Doesn't the above loop skip past the first block of the searched for characters if it's the last character before NUL in the range?
For example if the string between the pointers is "aaaabaabbb\0\0" and you search for 'b'.
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.
ah that's true - logic is really that it tries (fixing one bug soon) to find last character X but skip last ones if there is multiple--> is used to find "last" space....
strrevchr("aaaabaabbb\0\0" - 'b') --> bbb\0\0
add more documentation for function
| } | ||
| while (from > to) { | ||
| if (*from == ' ') { | ||
| return from+1; |
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.
So actually this returns a pointer to the character following the last space (ignoring trailing spaces).
Alright, makes sense now.
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.
yep
|
merged - please open ticket if you find any issues - as usual :). |
Status
READY
Migrations
NO
Description
Several improvements:
?-variablePS1-variable (possible to change using `set´ -cmd)cmd_request_screen_size(void)-> generates variables:COLUMNS,LINEStrueandfalse-commandsNOTE: known issues
"ab""cd"cause two arguments:["ab", "cd"]"\\\\"\"causes weird results:"\\\\"\"Todos