Skip to content

Automatically install completions #32

@seletz

Description

@seletz

Situation

Other homebrew packages automatically install shell completions. We don't.

Objective

Automatically install zsh, bash, and fish completions when users install via brew install odoo-work-cli.

Design

Cobra already provides a built-in completion subcommand — no Go code changes needed. GoReleaser's homebrew_casks has a native completions field.

Implementation

1. Add a completion generation script

scripts/completions.sh:

#!/bin/sh
set -e
rm -rf completions
mkdir completions
for sh in bash zsh fish; do
    go run ./cmd/odoo-work-cli completion "$sh" > "completions/odoo-work-cli.$sh"
done

2. Update .goreleaser.yml

  • Add the script to before.hooks
  • Include completion files in archives
  • Add completions to homebrew_casks
before:
  hooks:
    - go mod tidy
    - ./scripts/completions.sh

archives:
  - # ... existing fields ...
    files:
      - completions/*

homebrew_casks:
  - # ... existing fields ...
    completions:
      bash: "completions/odoo-work-cli.bash"
      zsh: "completions/odoo-work-cli.zsh"
      fish: "completions/odoo-work-cli.fish"

3. Document manual installation in README

For users not using homebrew:

# zsh (add to .zshrc)
eval "$(odoo-work-cli completion zsh)"

# bash
odoo-work-cli completion bash > /usr/local/etc/bash_completion.d/odoo-work-cli

# fish
odoo-work-cli completion fish | source

Metadata

Metadata

Assignees

Labels

CLICLI commands and featuresdocumentationImprovements or additions to documentationenhancementNew feature or requesthomebrewIssues related to brew packaging

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions