click-didyoumean
Adds git-style Did you mean suggestions to Click command-line groups
Repository Health
Technical Analysis
click-didyoumean is a small extension for the Click CLI framework that replicates git’s familiar “did you mean” behavior: when a user mistypes a subcommand, instead of just failing with a usage error, the CLI suggests the closest-matching registered command names.
It works by providing DYMGroup and DYMCommandCollection mixin classes that override Click’s resolve_command method, using Python’s built-in difflib.get_close_matches to compute similarity against all registered command names and appending matches above a configurable similarity cutoff to the raised UsageError. Adopting it requires no changes beyond passing cls=DYMGroup to @click.group(), making it a common ergonomic add-on for any multi-command Click-based CLI tool.
What You Get
- A
DYMGroupdrop-in replacement forclick.Groupthat adds did-you-mean suggestions on unmatched subcommands - A
DYMCommandCollectionvariant for CLIs composed from multipleclick.Groupsources - Configurable
max_suggestions(default 3) andcutoff(default 0.5) similarity parameters - Zero additional dependencies beyond Click itself and Python’s standard-library
difflib
Common Use Cases
- Improving UX on multi-command CLI tools by suggesting corrections for mistyped subcommands
- Adding git-style ergonomics to internal developer tools built with Click
- Providing helpful suggestions in CLIs composed from several
click.Groupsources viaDYMCommandCollection
Under The Hood
Architecture - The entire library is a DYMMixin class that overrides Click’s resolve_command() method: it first attempts the normal resolution via super(), and on a caught UsageError, calls difflib.get_close_matches() against the group’s registered command list, appending any matches above the cutoff threshold to the error message before re-raising; DYMGroup and DYMCommandCollection simply combine this mixin with click.Group and click.CommandCollection respectively. Tech Stack - Pure Python with a single runtime dependency on click itself, using only the standard-library difflib module for similarity matching — no third-party fuzzy-matching library is needed. Code Quality - The package has one test file covering the mixin’s suggestion behavior; the single-module implementation (src/click_didyoumean/__init__.py) is fully type-annotated and includes docstrings on every public class and method. API Design - Adoption requires only passing cls=DYMGroup to an existing @click.group() decorator, with two optional keyword arguments (max_suggestions, cutoff) for tuning — a minimal-friction, drop-in API that needs no restructuring of an existing Click CLI.
Used by 3 apps in this directory
knowhere
AI Development · Developer Tools
Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.
SWIRL
Search · Databases · Data Engineering
Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.
Taiga Back
Project Management · Developer Tools
Self-hosted agile project management backend with Scrum, Kanban, issue tracking, and a full REST API — built on Django and PostgreSQL.