Skip to content

feat: complete --output values in the shell - #616

Merged
fulviodenza merged 2 commits into
civo:masterfrom
Aubaid12:feat/output-flag-completion
Nov 9, 2026
Merged

fulviodenza merged 2 commits into
civo:masterfrom
Aubaid12:feat/output-flag-completion

Conversation

@Aubaid12

@Aubaid12 Aubaid12 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the suggestion on #608. Now that --output only accepts json, human and custom, the shell can complete those values instead of suggesting file names.

It's one RegisterFlagCompletionFunc call on the root command using cobra.FixedCompletions with common.OutputFormats, so the list stays in one place. Since --output is a persistent flag, every subcommand gets it too.

$ civo __complete instance ls --output ""
json
human
custom
:4
Completion ended with directive: ShellCompDirectiveNoFileComp

I also tried the generated bash script, and civo kubernetes ls -o c<TAB> completes to custom. The other shells go through the same __complete command, so they pick it up as well.

Tests: TestOutputFlagCompletesFormats in cmd/root_test.go checks the completion on the root command and on a subcommand, and fails if the registration is removed. go test ./... and golangci-lint pass.

@fulviodenza fulviodenza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PRs opened, I'm going to release these in the next tag

@fulviodenza
fulviodenza merged commit af4f990 into civo:master Nov 9, 2026
3 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