Refactor CLI from single positional argument (namespace) to command-based structure with namespace and search commands.
- Replace single
namespacepositional argument with command subparsers - Add
namespacesubcommand with namespace argument (current behavior) - Add
searchsubcommand with positionalpatternargument and optional--regex STRfilter - Maintain backward compatibility for existing flags (--no-color, --search-dirs, --verbose, --json, --completion, etc.)
- Update
Argsdataclass to include command type and search filters
- Create new
src/taskfile_help/search.pymodule - Implement pattern matching function (case-insensitive substring match)
- Implement regex matching function (compiled regex patterns)
- Create filter functions for:
- Namespace matching (filter taskfiles by namespace name)
- Group matching (filter groups within taskfiles)
- Task matching (filter individual tasks by name)
- Return filtered results in format compatible with existing output system
- Add command dispatcher after completion handling
- Route to
_handle_namespace_command()for namespace command - Route to
_handle_search_command()for search command - Maintain existing completion and output selection logic
- Extract current main logic into
_handle_namespace_command() - Keep existing behavior:
- Support for 'all', 'main', '?' special namespaces
- Single namespace display
- Error handling for missing namespaces
- No functional changes to current behavior
- Create
_handle_search_command()function - Load all taskfiles (main + all namespaces)
- Apply pattern/regex filters to:
- Namespace names → output all tasks in matching namespaces
- Group names → output tasks in matching groups
- Task names → output matching tasks
- Aggregate results and pass to outputter
- Add
output_search_results()method toOutputterprotocol - Implement in
TextOutputter:- Group results by namespace
- Show context (namespace/group) for each match
- Use existing formatting style
- Implement in
JsonOutputter:- Include match type (namespace/group/task)
- Include full context in JSON structure
- Update completion scripts to complete commands first (namespace, search)
- Add namespace completion after
namespacecommand - Add flag completion after
searchcommand (--pattern, --regex) - Update
get_completions()to handle command context - Note: Deferred - completion updates can be done in a follow-up
- Verify existing tests pass with new command structure
- Updated all tests to use new command structure (all 200 tests passing)
- Add tests for search filters in new
test_search.py(optional enhancement) - Add integration tests for search command with various filters (optional enhancement)
- Update README with new CLI usage examples
- Document filter behavior and match types
- Add examples for common search patterns
# Show main taskfile
taskfile-help namespace
taskfile-help namespace main
# Show specific namespace
taskfile-help namespace dev
taskfile-help namespace rag
# Show all taskfiles
taskfile-help namespace all
# List available namespaces
taskfile-help namespace ?# Search by pattern (case-insensitive substring)
taskfile-help search test
taskfile-help search lint
# Search with regex filter
taskfile-help search build --regex "^build.*"
taskfile-help search fix --regex ".*fix$"
# Combine pattern and regex (AND logic)
taskfile-help search lint --regex ".*fix$"- Subcommand structure: Use argparse subparsers for clean command separation
- Filter combination: Multiple filters use AND logic (all must match)
- Match hierarchy: Search order: namespace → group → task
- Output format: Reuse existing output methods with context annotations
- Backward compatibility: Consider adding default command behavior or migration path
- Steps 1-2 are independent and can be done in parallel
- Step 3 depends on step 1 (parser changes)
- Steps 4-5 depend on step 3 (command routing)
- Step 6 depends on step 5 (search results format)
- Step 7 depends on step 1 (command structure)
- Step 8 depends on steps 1-7 (all implementation)
- Step 9 can be done anytime after step 1
src/taskfile_help/config.py- CLI argument parsingsrc/taskfile_help/taskfile_help.py- Main entry point and command routingsrc/taskfile_help/output.py- Output formattingsrc/taskfile_help/completion.py- Shell completiontests/unit/test_config.py- Config teststests/unit/test_taskfile_help.py- Main logic testsREADME.md- Documentation
src/taskfile_help/search.py- Search and filter logictests/unit/test_search.py- Search tests
- Maintain existing behavior for namespace command
- Search command searches across namespaces, groups, and task names
- For namespace matches, output all tasks in the namespace using current output format
- For group matches, output the tasks in the group using current output format
- For task matches, output the tasks using current output format