-
Notifications
You must be signed in to change notification settings - Fork 111
feat(linenoise): Add linenoise library (IEC-328) #526
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
base: master
Are you sure you want to change the base?
feat(linenoise): Add linenoise library (IEC-328) #526
Conversation
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.
clang-tidy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
859aa9c
to
af22955
Compare
There was a PR about the linenoise library: espressif/esp-idf#10526 |
019e413
to
b4d3a0c
Compare
@suda-morris |
linenoise/linenoise/linenoise.h
Outdated
* @param param Pointer to the configuration parameters for the instance. | ||
* @return Handle to the created instance, or NULL on failure. | ||
*/ | ||
linenoise_handle_t linenoise_create_instance(linenoise_instance_param_t *param); |
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.
linenoise_handle_t linenoise_create_instance(linenoise_instance_param_t *param); | |
esp_err_t linenoise_create_instance(const linenoise_instance_param_t *param, linenoise_handle_t* out_handle); |
- Configuration structure can be a const pointer
- You may need to return different types of errors (out of RAM, invalid argument in the config structure, etc), which simply returning NULL doesn't allow. Hence, return esp_err_t and get the instance handle as an output argument.
linenoise/linenoise/linenoise.h
Outdated
* @param handle Handle to the instance to delete. | ||
* @return ESP_OK on success, or error code on failure. | ||
*/ | ||
esp_err_t linenoise_delete_instance(linenoise_handle_t handle); |
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 should the caller do if the "delete instance" function has returned an error?
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.
the only way the function returns an error is if the handle is invalid. I understand the question but then I would also expect that it is also valid for the comment above. So either I update the linenoise_create_instance to return error values and I leave this function as it is now or I update linenoise_delete_instance to abort when the handle is invalid and I keep the function linenoise_create_insance as it is now.
Because I am not sure what the caller can do if linenoise_create_instance returns e.g., no memory error.
linenoise/linenoise/linenoise.h
Outdated
* @param empty_line true to allow empty lines, false to disallow. | ||
* @return ESP_OK on success, or error code on failure. | ||
*/ | ||
esp_err_t linenoise_set_empty_line(linenoise_handle_t handle, bool empty_line); |
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.
Is there a use case for changing these settings (empty_line, multi_line, dumb_mode, max_cmd_line_length) once the instance is already created? If there is no concrete use case, it might be simpler to not implement these getters and setters.
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.
The user might want to repurpose an existing linenoise instance, instead of deleting the instance and creating a new one. In that case it might be useful to keep the getters and setters
e2dc2cc
to
0a0b3e9
Compare
68556ce
to
4530c52
Compare
@igrr, I updated the component based on your input. I left a few comments open for discussion. I added a bunch of tests for the basic functionality of linenoise when escape sequences are supported by the terminal. |
f564777
to
bca4fd1
Compare
d1158a1
to
fb1f7f8
Compare
fb1f7f8
to
a8e73ef
Compare
a8e73ef
to
6e3c7a0
Compare
The check that the user added the component to the bug-report.yml file ius missing in the list of condition to meet for the PR to be receivable.
c210664
to
b0f7a27
Compare
b0f7a27
to
8ca437b
Compare
8ca437b
to
c4b9cb9
Compare
c4b9cb9
to
b3c5ebb
Compare
Checklist
url
field definedChange description
Add linenoise to the list of extra components. The library is used in the console component of esp-idf that is going through refactoring. One part of the refactoring is to move third party libraries outside of the console component. Eventually, the console component itself will be removed from esp-idf, reason why this PR adds the linenoise lib to the idf-extra-components.