Skip to content

add shell completions (bash/zsh/fish/PowerShell) #142

@bmertens-datum

Description

@bmertens-datum

Summary

datumctl has no shell completions today. Users tab-completing commands,
subcommands, flags, and resource type names get nothing. Cobra has built-in
completion support — the bulk of the work is wiring it up and adding dynamic
completion for resource type arguments.

Note: This is a human UX feature. AI tools and automated pipelines
construct commands programmatically and do not benefit from shell completions.
The target audience is developers typing datumctl interactively in a terminal.

What should complete

Input Completes to
datumctl <TAB> subcommands (get, apply, auth, ai, …)
datumctl get <TAB> resource types fetched live from api-resources (e.g. projects, dnszones, domains)
datumctl describe <TAB> same as above
datumctl delete <TAB> same as above
datumctl edit <TAB> same as above
datumctl explain <TAB> same as above
datumctl auth <TAB> auth subcommands
datumctl --<TAB> flags for the current command

Implementation notes

Cobra's completion command (cmd.GenBashCompletion, GenZshCompletion, etc.)
handles static command/flag completion out of the box — just add the completion
command to root.

Dynamic resource type completion requires registering a ValidArgsFunction on
get, describe, delete, edit, and explain that calls the API and returns
resource type names. This is the same data datumctl api-resources returns; the
completion function can reuse that path.

The completion command should be hidden from the main help group (same pattern as
generate-cli-docs) since it is a setup utility, not an everyday command.

Acceptance criteria

  • datumctl completion bash / zsh / fish / powershell outputs a valid completion script
  • datumctl get <TAB> completes with live resource types
  • datumctl describe/delete/edit/explain <TAB> get the same dynamic completions
  • Flags complete on all commands

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions