add an example of finding close matches (#1152)

continue discussion on #1149 
Adds subcommand prefix matching as a modifier to CLI.  
Adds an example of close matching logic for further exploration.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top
2025-05-21 19:39:00 -07:00
committed by GitHub
parent 50591fb666
commit 5602f2b438
8 changed files with 330 additions and 10 deletions

View File

@@ -105,6 +105,7 @@ at the point the subcommand is created:
- Fallthrough
- Group name
- Max required subcommands
- prefix_matching
- validate positional arguments
- validate optional arguments
@@ -156,6 +157,14 @@ ignored, even if they could match. Git is the traditional example for prefix
commands; if you run git with an unknown subcommand, like "`git thing`", it then
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.
### Silent subcommands
Subcommands can be modified by using the `silent` option. This will prevent the