Skip to content

Commit

Permalink
Package shell completions automatically (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
felicianotech committed Sep 15, 2022
1 parent 020d8bc commit ab79ee4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
completions

# Binaries
/arc/arc
/dist/
23 changes: 23 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
project_name: arc

before:
hooks:
- ./scripts/completions.sh

builds:
- dir: arc
goos:
Expand All @@ -24,6 +28,7 @@ archives:
files:
- LICENSE
- README.md
- completions/*
replacements:
darwin: macos

Expand All @@ -39,6 +44,19 @@ nfpms:
bindir: /usr/bin
conflicts:
- arc
contents:
- src: ./completions/arc.bash
dst: /usr/share/bash-completion/completions/arc
file_info:
mode: 0644
- src: ./completions/arc.fish
dst: /usr/share/fish/completions/arc.fish
file_info:
mode: 0644
- src: ./completions/arc.zsh
dst: /usr/share/zsh/vendor-completions/_arc
file_info:
mode: 0644

brews:
- tap:
Expand All @@ -52,6 +70,11 @@ brews:
description: "A helpful CircleCI and GitHub tool."
test: |
system "#{bin}/arc", "help"
install: |-
bin.install "arc"
bash_completion.install "completions/arc.bash" => "arc"
fish_completion.install "completions/arc.fish"
zsh_completion.install "completions/arc.zsh" => "_arc"
checksum:
name_template: "{{ .ProjectName }}-v{{ .Version }}-checksums.txt"
10 changes: 10 additions & 0 deletions scripts/completions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

rm -rf ./completions
mkdir ./completions

for sh in bash fish zsh; do
go run ./arc/main.go completion "$sh" >"completions/arc.$sh"
done

0 comments on commit ab79ee4

Please sign in to comment.