Skip to content

[Feature]: auto install of completions via install script #338

Description

@lockwobr

Prerequisites

  • I searched existing issues

Feature Summary

  • Add auto install via install script tab completions.
  • Also support home brew.

Problem/Use Case

The aicr CLI already supports shell completion via aicr completion bash|zsh|fish|pwsh (urfave/cli v3), but users must manually configure it as a post-install step. Most users never discover this, so they miss out on tab completion for commands and flags.

Proposed Solution

Proposal

Make shell completion automatic for both install paths:

1. Install script (./install)

Add a setup_completions function that runs after the binary is installed:

  • Detect shell from $SHELL (bash, zsh, fish)
  • Write completion scripts to auto-loaded directories (file-based, not RC-based):
    • Bash: /usr/share/bash-completion/completions/aicr → fallback to ~/.local/share/bash-completion/completions/aicr
    • Zsh: /usr/local/share/zsh/site-functions/_aicr → fallback to ~/.local/share/zsh/site-functions/_aicr
    • Fish: ~/.config/fish/completions/aicr.fish
  • Permission handling: try direct write, fall back to sudo, then fall back to user-local XDG directories
  • Non-fatal: completion failure warns but never breaks the install (|| true)
  • Opt-out: -s flag or AICR_NO_COMPLETIONS=1 env var to skip
  • Uses absolute binary path ("${INSTALL_DIR}/${BIN_NAME}") since $PATH may not include the install dir yet

2. Homebrew formula (.goreleaser.yaml)

Add install and test blocks to the brews section:

    install: |
      bin.install "aicr"
      generate_completions_from_executable(bin/"aicr", "completion")
    test: |
      assert_match version.to_s, shell_output("#{bin}/aicr --version")

generate_completions_from_executable is a Homebrew built-in that handles bash, zsh, and fish completions automatically.

## 3. Documentation updates
Update `docs/user/installation.md` and `site/content/docs/user/installation.md:`
- Note that completions are now automatic
- Document the -s skip flag
- Keep manual instructions for additional shells
- Update uninstall section with completion file paths to clean up

### Success Criteria

Install script automatically sets up tab completions

### Alternatives Considered

_No response_

### Component

CLI (aicr)

### Priority

Nice to have

### Compatibility / Breaking Changes

_No response_

### Operational Considerations

_No response_

### Are you willing to contribute?

_No response_

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions