Skip to content

feat: add dynamic shell completions for all commands#40

Merged
rbansal42 merged 3 commits intodevfrom
feature/dynamic-completions
Feb 13, 2026
Merged

feat: add dynamic shell completions for all commands#40
rbansal42 merged 3 commits intodevfrom
feature/dynamic-completions

Conversation

@rbansal42
Copy link
Owner

Summary

  • Add comprehensive dynamic tab-completion support using Cobra's RegisterFlagCompletionFunc and ValidArgsFunction APIs
  • Create shared completion helper module (internal/cmdutil/completion.go) with reusable functions for both static and API-backed completions
  • Register completions across all 41+ command files

What Changed

New Files

  • internal/cmdutil/completion.go — Shared completion helper module with static and dynamic completion functions
  • internal/cmdutil/completion_test.go — Tests for static completion helpers and filterPrefix
  • docs/plans/2026-02-13-dynamic-shell-completions.md — Implementation plan

Completion Types Added

Type Flags/Args Source
Static enums --state, --kind, --priority Hard-coded valid values
Workspace names --workspace API: ListWorkspaces
Repository names --repo API: ListRepositories
Branch names --base, --head, --target, --branch API: ListBranches
Reviewer/assignee --reviewer, --assignee API: ListWorkspaceMembers
PR numbers positional arg <number> API: ListPullRequests
Issue IDs positional arg <issue-id> API: ListIssues
Branch names positional arg <branch-name> API: ListBranches

Safety

  • All dynamic completions fail silently on auth/network errors (return nil, never crash)
  • 5-second timeout on all API calls during completion
  • No existing command logic was modified

Testing

  • All existing tests pass
  • New tests cover StaticFlagCompletion, filterPrefix (including tab-separated values), and completionCtx
  • Build compiles cleanly

Related Issues

Follow-up improvements tracked in: #35, #36, #37, #38, #39

rbansal42 and others added 3 commits February 6, 2026 12:32
merge: dev into main — dedup refactor, type cleanup, Dockerfile
Add comprehensive tab-completion support using Cobra's RegisterFlagCompletionFunc
and ValidArgsFunction APIs. Includes:

- Shared completion helper module (internal/cmdutil/completion.go)
- Static enum completions for --state, --kind, --priority flags
- Dynamic API-backed completions for --workspace, --repo, --base/--head,
  --reviewer/--assignee flags
- Positional arg completions for PR numbers, issue IDs, branch names
- All completions fail silently on auth/network errors (no crashes)
- Tests for static completion helpers
- Add --base branch completion to pr edit command
- Add --assignee completion to issue list command
- Add tests for filterPrefix with tab-separated values
@rbansal42 rbansal42 merged commit 8e1c401 into dev Feb 13, 2026
2 checks passed
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.

2 participants