Summary
Add distill completion command that generates shell completions for Bash, Zsh, Fish, and PowerShell.
Motivation
Shell completions are a low-effort, high-polish feature that signals CLI maturity. Cobra provides built-in support.
Implementation
Cobra has built-in completion generation. Add a completion command:
// cmd/completion.go
var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate shell completion scripts",
Long: `Generate shell completion scripts for Distill CLI.
Bash:
$ distill completion bash > /etc/bash_completion.d/distill
Zsh:
$ distill completion zsh > "${fpath[1]}/_distill"
Fish:
$ distill completion fish > ~/.config/fish/completions/distill.fish
PowerShell:
PS> distill completion powershell | Out-String | Invoke-Expression`,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
switch args[0] {
case "bash":
return rootCmd.GenBashCompletion(os.Stdout)
case "zsh":
return rootCmd.GenZshCompletion(os.Stdout)
case "fish":
return rootCmd.GenFishCompletion(os.Stdout, true)
case "powershell":
return rootCmd.GenPowerShellCompletionWithDesc(os.Stdout)
}
return fmt.Errorf("unsupported shell: %s", args[0])
},
}
Deliverables
Acceptance Criteria
Summary
Add
distill completioncommand that generates shell completions for Bash, Zsh, Fish, and PowerShell.Motivation
Shell completions are a low-effort, high-polish feature that signals CLI maturity. Cobra provides built-in support.
Implementation
Cobra has built-in completion generation. Add a
completioncommand:Deliverables
cmd/completion.go- Completion commandAcceptance Criteria
distill completion bashoutputs valid bash completiondistill completion zshoutputs valid zsh completiondistill se<TAB>yieldsservedistill api --p<TAB>yields--port)