feat: add --contains flag to filter words by required letters

Adds a new --contains argument that only includes words containing all
specified letters, complementing the existing --exclude functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-22 20:57:21 -05:00
parent 847bdccfa2
commit 92d7a99594

View File

@@ -22,6 +22,11 @@ def main() -> int:
metavar="LETTERS",
help="Exclude words containing any of these letters (case-insensitive)",
)
parser.add_argument(
"--contains",
metavar="LETTERS",
help="Only include words that contain all of these letters (case-insensitive)",
)
parser.add_argument(
"--mask",
metavar="PATTERN",
@@ -50,6 +55,7 @@ def main() -> int:
only_set = set(args.only.lower()) if args.only else None
exclude_set = set(args.exclude.lower()) if args.exclude else None
contains_set = set(args.contains.lower()) if args.contains else None
# Prepare matchers
# Validate and normalize mask
@@ -90,6 +96,8 @@ def main() -> int:
return False
if exclude_set is not None and (set(word.lower()) & exclude_set):
return False
if contains_set is not None and not (contains_set <= set(word.lower())):
return False
if mask_positions is not None:
wl = word.lower()
for i, ch in enumerate(mask_positions):