From 866bf728d877c1109f1264b61e80d341ca0a90f8 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Tue, 15 Jun 2021 09:36:32 +0300 Subject: [PATCH] completion: include completions in archives, linux packages and homebrew This PR includes the completions script generated by `pscale completion` and adds them for the macOS and Linux packages. That way the user doesn't have to manually generate and install the completion scripts. --- .gitignore | 4 +--- .goreleaser.yml | 18 ++++++++++++++++++ script/completions | 10 ++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 script/completions diff --git a/.gitignore b/.gitignore index 5800750a..082cb84f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -# Dependency directories (remove the comment below to include it) -# vendor/ - dist/ +completions/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 742aae28..af901bbb 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,6 +1,10 @@ project_name: pscale release: prerelease: auto # don't publish release with -rc1,-pre, etc suffixes +before: + hooks: + - go mod tidy + - ./script/completions builds: - env: - CGO_ENABLED=0 @@ -29,6 +33,13 @@ nfpms: description: The PlanetScale CLI homepage: https://github.com/planetscale/cli license: Apache 2.0 + contents: + - src: ./completions/pscale.bash + dst: /etc/bash_completion.d/pscale + - src: ./completions/pscale.fish + dst: /usr/share/fish/completions/pscale.fish + - src: ./completions/pscale.zsh + dst: /usr/local/share/zsh/site-functions/_pscale formats: - deb - rpm @@ -50,12 +61,19 @@ brews: system "#{bin}/pscale --version" install: | bin.install "pscale" + bash_completion.install "completions/pscale.bash" => "pscale" + zsh_completion.install "completions/pscale.zsh" => "_pscale" + fish_completion.install "completions/pscale.fish" archives: - replacements: darwin: macOS format_overrides: - goos: windows format: zip + files: + - README.md + - LICENSE + - completions/* snapshot: name_template: "{{ .Tag }}-next" changelog: diff --git a/script/completions b/script/completions new file mode 100755 index 00000000..e1e896e3 --- /dev/null +++ b/script/completions @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +rm -rf completions +mkdir -p completions + +for sh in bash zsh fish; do + go run cmd/pscale/main.go completion "$sh" >"completions/pscale.$sh" +done