Skip to content

feat: add shell tab completion for query command options - #25

Merged
codeasier merged 2 commits into
mainfrom
feat/shell-completion
Apr 17, 2026
Merged

codeasier merged 2 commits into
mainfrom
feat/shell-completion

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

Add shell tab completion for pt-snap query command options using Typer's built-in shell completion support:

Option Completion
--template-use Registered template names (e.g., leak_detection, active_blocks)
--template-info Same as above
--category basic, statistical, business
--device Device IDs from the resolved database (e.g., 0, 1)

How it works:

  • New src/pt_snap_cli/completion.py module with completion functions
  • Device ID completion resolves DB path from env > project context > global config
  • Template and category completion use the existing registry

Enable completion:

pt-snap --install-completion
# Then restart your shell

Supports bash, zsh, and fish out of the box (via Typer/Click).

🔗 Related Issue

Fixes #1

🧪 Testing

  • Tests added — 9 new test cases for completion functions
  • Manual testing completed
  • 200 tests pass total

✅ Checklist

  • Code follows project guidelines
  • No new warnings introduced
  • Changes tested locally

codeasier added 2 commits April 17, 2026 21:17
Add autocompletion for pt-snap query options using Typer's built-in
shell completion support:

- --template-use and --template-info: complete from registered template names
- --category: complete with basic/statistical/business
- --device: complete device IDs from the resolved database (env > project > global)

A new src/pt_snap_cli/completion.py module provides the completion
functions, including lazy DB resolution for device ID discovery.

Users can enable completion with: pt-snap --install-completion

Closes #1
The default was add_completion=False which disables --install-completion
and --show-completion flags. Changed to True so users can enable
shell tab completion.
@codeasier
codeasier merged commit a94b44c into main Apr 17, 2026
5 checks passed
@codeasier
codeasier deleted the feat/shell-completion branch April 17, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 增强 pt-snap query 命令的 tab 补全能力

1 participant