Refactor/line reader#13330
Conversation
632992d to
ab7924c
Compare
…ler way The LineReader is made a concrete class whose declaration is independent of the readline library. Only its implementation depends on the presence or absence of the readline library. The LineReader code is embedded in a new library : line_reader, to make the cli library independant of the USE_READLINE definition.
ab7924c to
f2a3033
Compare
|
Is the NCurses dependency really needed for this? I don't really get the idea behind this whole change. |
|
Hello @varjolintu and thank you for reviewing my pull request. Your question touches on two points:
|
|
I've just realized that it is not necessary to introduce the FindNcurses module because it already exists one in the CMake modules library: https://cmake.org/cmake/help/latest/module/FindCurses.html. On the other hand, I admit that I have not found any trace of the readline library's dependency on the ncurses library anywhere other than on vcpkg and the Ncurses_LIBRARY variable. What is your experience with this? |
|
I finally found the repository of the readline library: git://git.git.savannah.gnu.org/readline.git.
This is an option passed to the configure script. So it seems that the (n)curses library may not be mandatory, if the --with-curses option is NOT passed to the configure script. So what is your recommandation with this change? Should I let the FindReadline module unchanged even if on the vcpkg website we can see that the readline library requires the ncurses library? |
|
We do not use vcpkg on linux. If ncurses is a dependency of readline on macOS then finding the readline library would be sufficient as that should also bring in the ncurses library as needed. If we dont directly utilize a library than we shouldn't need to "find" it and link to it directly. |
e8e9876 to
4b8c0fb
Compare
|
Ok I've updated my change by removing the FindNcurses module and every reference to the ncurses library. |
The readline library is now searched with pkg-config first. If pkg-config is not installed, the search is manual. In both cases, the Readline::readline target is created, embedding transitive requirements. FindReadline module was written with the help of Le Chat AI (https://chat.mistral.ai/chat)
4b8c0fb to
522cfe6
Compare
These changes make the LineReader class a concrete class whose implementation depends on whether or not USE_READLINE is defined. This greatly simplifies keepassxc-cli.cpp.
The readline library's search and internal and public variables now conform to the CMake standard (https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html).
If the readline library is not found, the LineReader class then depends on the TextStream class. The cli library also depends on the TextStream class, but only for its implementation (Export.cpp).
These relationships are now expressed between the line_reader, text_stream, and cli libraries.
Also, by putting the code of LineReader in the line_reader library, we isolate the use of USE_READLINE into the single line_reader library. The cli library does not use anymore the USE_READLINE definition.
Finally, the new version of the search modules allows the use of CMake's modern library dependency syntax.
The FindReadline.cmake module was written with the help of Le Chat (https://chat.mistral.ai/chat).
Type of change