feat(tpagectl): implement completion command #583

Merged
fuzzy merged 2 commits from feat/cli-completion into main 2026-08-07 06:56:29 +00:00
Owner

What

Implements the completion command using the urfave/cli v3 framework's built-in completion support.

  • Root command sets EnableShellCompletion: true, which registers the built-in completion command with bash, zsh, fish, and pwsh (PowerShell) subcommands that emit the framework's embedded autocomplete scripts (#243).
  • ConfigureShellCompletionCommand unhides the command so it appears in tpagectl --help.
  • No new package or dependency — the framework provides the scripts.

Why

Phase 5 roadmap task #245.

Testing

  • Root help lists completion
  • completion --help lists bash/zsh/fish/pwsh subcommands
  • Each shell subcommand emits a non-empty script; bash/zsh/fish reference the tpagectl binary (pwsh derives it from $MyInvocation)
  • go test -race ./... passes (21 packages)
  • golangci-lint run clean
  • pre-commit hooks pass (gofmt, go mod tidy, go test)

Breaking Changes

None.

Notes

#244 says "follow cobra's built-in completion support", but the CLI framework is urfave/cli v3 (chosen in #147), so we follow its built-in completion support instead — the roadmap reference is noted as a deviation.

Closes #243
Closes #244
Closes #245

## What Implements the `completion` command using the urfave/cli v3 framework's built-in completion support. - Root command sets `EnableShellCompletion: true`, which registers the built-in `completion` command with `bash`, `zsh`, `fish`, and `pwsh` (PowerShell) subcommands that emit the framework's embedded autocomplete scripts (#243). - `ConfigureShellCompletionCommand` unhides the command so it appears in `tpagectl --help`. - No new package or dependency — the framework provides the scripts. ## Why Phase 5 roadmap task #245. ## Testing - [x] Root help lists `completion` - [x] `completion --help` lists bash/zsh/fish/pwsh subcommands - [x] Each shell subcommand emits a non-empty script; bash/zsh/fish reference the `tpagectl` binary (pwsh derives it from `$MyInvocation`) - [x] `go test -race ./...` passes (21 packages) - [x] `golangci-lint run` clean - [x] pre-commit hooks pass (gofmt, go mod tidy, go test) ## Breaking Changes None. ## Notes #244 says "follow cobra's built-in completion support", but the CLI framework is **urfave/cli v3** (chosen in #147), so we follow *its* built-in completion support instead — the roadmap reference is noted as a deviation. Closes #243 Closes #244 Closes #245
Enable urfave/cli's built-in completion command, which emits autocomplete
scripts for bash, zsh, fish, and PowerShell. The completion command is
unhidden via ConfigureShellCompletionCommand so it appears in root help.
docs(roadmap): mark completion command complete
All checks were successful
Test and Release / lint (pull_request) Successful in 7m48s
Test and Release / test (pull_request) Successful in 8m6s
f42a79ead6
Record completion of the tpagectl completion command using urfave/cli's
built-in completion support, which generates scripts for bash, zsh, fish,
and PowerShell. The roadmap referenced cobra's built-in completion; the
CLI framework is urfave/cli v3, so its built-in support is used instead.

closes #243
closes #244
closes #245
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-07 06:48:57 +00:00
the.auditor left a comment

Summary

completion command for tpagectl using urfave/cli v3's built-in shell completion. Verified: go test -race ./... passes (21 packages) and golangci-lint run ./... is clean. Closes #243-245.

Verified framework usage: EnableShellCompletion: true registers cli v3's built-in completion command with bash/zsh/fish/pwsh subcommands (confirmed in the module source), and ConfigureShellCompletionCommand unhides it correctly for tpagectl --help.

No blocking issues; no new issues filed.

References (covered by existing issues)

  1. completion (like version) runs the root Before hook, so an invalid server config would break completion even though it never contacts the daemon — extends #582.

Note

#244 says "follow cobra's built-in completion support", but the CLI framework is urfave/cli v3 (chosen in #147); the PR documents the deviation and honors the intent (use the framework's built-in completion). Acceptable.

Praise

  • Framework-native completion: no new dependency or package
  • Clean unhide via ConfigureShellCompletionCommand
  • Solid tests: root help lists the command, --help lists all shells, each shell emits a non-empty script referencing the binary
  • Honest #244 deviation note
## Summary `completion` command for tpagectl using urfave/cli v3's built-in shell completion. Verified: `go test -race ./...` passes (21 packages) and `golangci-lint run ./...` is clean. Closes #243-245. Verified framework usage: `EnableShellCompletion: true` registers cli v3's built-in `completion` command with `bash`/`zsh`/`fish`/`pwsh` subcommands (confirmed in the module source), and `ConfigureShellCompletionCommand` unhides it correctly for `tpagectl --help`. No blocking issues; no new issues filed. ## References (covered by existing issues) 1. `completion` (like `version`) runs the root `Before` hook, so an invalid server config would break completion even though it never contacts the daemon — extends #582. ## Note #244 says "follow cobra's built-in completion support", but the CLI framework is urfave/cli v3 (chosen in #147); the PR documents the deviation and honors the intent (use the framework's built-in completion). Acceptable. ## Praise - Framework-native completion: no new dependency or package - Clean unhide via `ConfigureShellCompletionCommand` - Solid tests: root help lists the command, `--help` lists all shells, each shell emits a non-empty script referencing the binary - Honest #244 deviation note
fuzzy merged commit f42a79ead6 into main 2026-08-07 06:56:29 +00:00
fuzzy deleted branch feat/cli-completion 2026-08-07 06:56:29 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!583
No description provided.