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

style: pre-commit.ci fixes

This commit is contained in:
pre-commit-ci[bot] 2025-05-02 14:47:49 +00:00
parent 433ee18d0c
commit 94f08d9c20
3 changed files with 27 additions and 20 deletions

View File

@ -914,8 +914,11 @@ option_groups. These are:
is not allowed to have a single character short option starting with the same
character as a single dash long form name; for example, `-s` and `-single` are
not allowed in the same application.
- `.allow_subcommand_prefix_matching()`:🚧 If this modifier is enabled, unambiguious prefix portions of a subcommand will match.
For example `upgrade_package` would match on `upgrade_`, `upg`, `u` as long as no other subcommand would also match. It also disallows subcommand names that are full prefixes of another subcommand.
- `.allow_subcommand_prefix_matching()`:🚧 If this modifier is enabled,
unambiguious prefix portions of a subcommand will match. For example
`upgrade_package` would match on `upgrade_`, `upg`, `u` as long as no other
subcommand would also match. It also disallows subcommand names that are full
prefixes of another subcommand.
- `.fallthrough()`: Allow extra unmatched options and positionals to "fall
through" and be matched on a parent option. Subcommands by default are allowed
to "fall through" as in they will first attempt to match on the current

View File

@ -159,8 +159,11 @@ calls another command called "`git-thing`" with the remaining options intact.
### prefix matching
A modifier is available for subcommand matching, `->allow_subcommand_prefix_matching()`. if this is enabled unambiguious prefix portions of a subcommand will match.
For Example `upgrade_package` would match on `upgrade_`, `upg`, `u` as long as no other subcommand would also match. It also disallows subcommand names that are full prefixes of another subcommand.
A modifier is available for subcommand matching,
`->allow_subcommand_prefix_matching()`. if this is enabled unambiguious prefix
portions of a subcommand will match. For Example `upgrade_package` would match
on `upgrade_`, `upg`, `u` as long as no other subcommand would also match. It
also disallows subcommand names that are full prefixes of another subcommand.
### Silent subcommands

View File

@ -9,16 +9,18 @@
#include <CLI/CLI.hpp>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#include <numeric>
// Levenshtein distance function code generated by chatgpt/copilot
std::size_t levenshteinDistance(const std::string &s1, const std::string &s2) {
std::size_t len1 = s1.size(), len2 = s2.size();
if (len1 == 0) return len2;
if (len2 == 0) return len1;
if(len1 == 0)
return len2;
if(len2 == 0)
return len1;
std::vector<std::size_t> prev(len2 + 1), curr(len2 + 1);
std::iota(prev.begin(), prev.end(), 0); // Fill prev with {0, 1, ..., len2}
@ -110,8 +112,7 @@ int main(int argc, const char* argv[]) {
CLI11_PARSE(app, argc, argv);
auto subs = app.get_subcommands();
for (const auto& sub : subs)
{
for(const auto &sub : subs) {
std::cout << sub->get_name() << "\n";
}
return 0;