mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-04 22:23:52 +00:00
update some code and change the levenshteinDistance to only work with C++14 or higher
This commit is contained in:
parent
94f08d9c20
commit
7bc28a9a69
@ -250,6 +250,7 @@ set_property(TEST retired_retired_test3 PROPERTY PASS_REGULAR_EXPRESSION "WARNIN
|
||||
|
||||
set_property(TEST retired_deprecated PROPERTY PASS_REGULAR_EXPRESSION "deprecated.*not_deprecated")
|
||||
|
||||
if(CMAKE_CXX_STANDARD GREATER 13)
|
||||
add_cli_exe(close_match close_match.cpp)
|
||||
|
||||
add_test(NAME close_match_test COMMAND close_match i)
|
||||
@ -264,7 +265,7 @@ set_property(TEST close_match_test2 PROPERTY PASS_REGULAR_EXPRESSION "upgrade")
|
||||
set_property(TEST close_match_test3 PROPERTY PASS_REGULAR_EXPRESSION "remove")
|
||||
|
||||
set_property(TEST close_match_test4 PROPERTY PASS_REGULAR_EXPRESSION "closest match is upgrade")
|
||||
|
||||
endif()
|
||||
#--------------------------------------------
|
||||
add_cli_exe(custom_parse custom_parse.cpp)
|
||||
add_test(NAME cp_test COMMAND custom_parse --dv 1.7)
|
||||
|
@ -13,6 +13,9 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
//only works with C++14 or higher
|
||||
|
||||
// Levenshtein distance function code generated by chatgpt/copilot
|
||||
std::size_t levenshteinDistance(const std::string &s1, const std::string &s2) {
|
||||
@ -75,7 +78,7 @@ void addSubcommandCloseMatchDetection(CLI::App *app, std::size_t minDistance = 3
|
||||
}
|
||||
}
|
||||
// add a callback that runs before a final callback and loops over the remaining arguments for subcommands
|
||||
app->parse_complete_callback([&app, minDistance, list]() {
|
||||
app->parse_complete_callback([&app, minDistance,list=std::move(list)]() {
|
||||
auto extras = app->remaining();
|
||||
if(extras.empty()) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user