Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ release-cargo-publish:
# "homebrew" to publish-jobs in dist-workspace.toml, the cargo-dist
# workflow takes over, and this recipe becomes a manual-recovery fallback.
#
# cargo-dist's homebrew template installs the binary but doesn't wire up
# shell completions, so this recipe patches the generated formula to run
# `qn completions <shell>` at install time. The patch is idempotent and
# hard-fails if cargo-dist's install-method anchor goes missing — if you
# hit that error, the template changed and the patch below needs updating.
# When homebrew publishing is automated in CI, this patch moves with it.
#
# Usage: just release-update-homebrew-tap 0.1.0 ~/qn/homebrew-tap
#
# Precondition: tap_path is a clean local clone of quicknode/homebrew-tap
Expand Down Expand Up @@ -78,6 +85,30 @@ release-update-homebrew-tap version tap_path:
mkdir -p Formula
cp /tmp/qn.rb Formula/qn.rb
rm /tmp/qn.rb
# Wire up shell completions: cargo-dist's formula installs the binary but
# not completions. `qn completions <shell>` is a pure local generator (no
# key, no network), so it's safe to run during `brew install`. Insert the
# helper after the `install_binary_aliases!` anchor in the generated
# install method. Idempotent (skip if already present); fail loud if the
# anchor is gone so a cargo-dist template change can't silently drop it.
if ! grep -q 'generate_completions_from_executable' Formula/qn.rb; then
if ! grep -q '^[[:space:]]*install_binary_aliases!$' Formula/qn.rb; then
echo "Error: 'install_binary_aliases!' anchor not found in generated qn.rb." >&2
echo "cargo-dist's formula template may have changed; the completions" >&2
echo "patch in release-update-homebrew-tap needs updating." >&2
exit 1
fi
awk '
{ print }
/^[[:space:]]*install_binary_aliases!$/ {
match($0, /^[[:space:]]*/)
indent = substr($0, 1, RLENGTH)
print ""
print indent "generate_completions_from_executable(bin/\"qn\", \"completions\")"
}
' Formula/qn.rb > Formula/qn.rb.tmp
mv Formula/qn.rb.tmp Formula/qn.rb
fi
git add Formula/qn.rb
if git diff --cached --quiet; then
echo "Formula/qn.rb is already at v{{version}} on main. Nothing to do."
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Pick the recommended path for your platform. Other channels are listed under [Al
brew install quicknode/tap/qn
```

Homebrew installs shell completions automatically — open a new shell after
install (zsh users may need one `compinit` refresh) and `qn <TAB>` works.

### Scoop (Windows)

```powershell
Expand Down Expand Up @@ -242,6 +245,9 @@ qn team list

## Shell completions

Homebrew installs completions automatically (see above). For other install
methods, generate them yourself:

```sh
qn completions zsh > ~/.zfunc/_qn # zsh
qn completions bash > /etc/bash_completion.d/qn # bash
Expand Down
Loading