1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-04 22:23:52 +00:00

style: pre-commit.ci fixes

This commit is contained in:
pre-commit-ci[bot] 2025-05-02 15:51:39 +00:00
parent 7bc28a9a69
commit 414bff9d92
2 changed files with 12 additions and 12 deletions

View File

@ -251,20 +251,20 @@ set_property(TEST retired_retired_test3 PROPERTY PASS_REGULAR_EXPRESSION "WARNIN
set_property(TEST retired_deprecated PROPERTY PASS_REGULAR_EXPRESSION "deprecated.*not_deprecated") set_property(TEST retired_deprecated PROPERTY PASS_REGULAR_EXPRESSION "deprecated.*not_deprecated")
if(CMAKE_CXX_STANDARD GREATER 13) if(CMAKE_CXX_STANDARD GREATER 13)
add_cli_exe(close_match close_match.cpp) add_cli_exe(close_match close_match.cpp)
add_test(NAME close_match_test COMMAND close_match i) add_test(NAME close_match_test COMMAND close_match i)
add_test(NAME close_match_test2 COMMAND close_match upg) add_test(NAME close_match_test2 COMMAND close_match upg)
add_test(NAME close_match_test3 COMMAND close_match rem) add_test(NAME close_match_test3 COMMAND close_match rem)
add_test(NAME close_match_test4 COMMAND close_match upgrde) add_test(NAME close_match_test4 COMMAND close_match upgrde)
set_property(TEST close_match_test PROPERTY PASS_REGULAR_EXPRESSION "install") set_property(TEST close_match_test PROPERTY PASS_REGULAR_EXPRESSION "install")
set_property(TEST close_match_test2 PROPERTY PASS_REGULAR_EXPRESSION "upgrade") 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_test3 PROPERTY PASS_REGULAR_EXPRESSION "remove")
set_property(TEST close_match_test4 PROPERTY PASS_REGULAR_EXPRESSION "closest match is upgrade") set_property(TEST close_match_test4 PROPERTY PASS_REGULAR_EXPRESSION "closest match is upgrade")
endif() endif()
#-------------------------------------------- #--------------------------------------------
add_cli_exe(custom_parse custom_parse.cpp) add_cli_exe(custom_parse custom_parse.cpp)

View File

@ -7,15 +7,15 @@
// Code inspired by discussion from https://github.com/CLIUtils/CLI11/issues/1149 // Code inspired by discussion from https://github.com/CLIUtils/CLI11/issues/1149
#include <CLI/CLI.hpp> #include <CLI/CLI.hpp>
#include <algorithm>
#include <iostream> #include <iostream>
#include <limits> #include <limits>
#include <numeric> #include <numeric>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <algorithm>
//only works with C++14 or higher // only works with C++14 or higher
// Levenshtein distance function code generated by chatgpt/copilot // Levenshtein distance function code generated by chatgpt/copilot
std::size_t levenshteinDistance(const std::string &s1, const std::string &s2) { std::size_t levenshteinDistance(const std::string &s1, const std::string &s2) {
@ -78,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 // add a callback that runs before a final callback and loops over the remaining arguments for subcommands
app->parse_complete_callback([&app, minDistance,list=std::move(list)]() { app->parse_complete_callback([&app, minDistance, list = std::move(list)]() {
auto extras = app->remaining(); auto extras = app->remaining();
if(extras.empty()) { if(extras.empty()) {
return; return;