Skip to content

Commit

Permalink
feat: add auto complete
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Jul 18, 2023
1 parent d601133 commit 1d1fab2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/fctl/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
autocomplete.*
fctl
coverage.*
completions
11 changes: 11 additions & 0 deletions components/fctl/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# source about auto completion = https://carlosbecker.com/posts/golang-completions-cobra/

project_name: fctl
includes:
- from_file:
Expand Down Expand Up @@ -25,6 +27,10 @@ builds:
- amd64
- arm64

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

archives:
- id: "{{.ProjectName}}"
builds:
Expand All @@ -34,6 +40,8 @@ archives:
format: zip
format: tar.gz
name_template: "{{.ProjectName}}_{{.Os}}-{{.Arch}}"
files:
- completions/*

brews:
- tap:
Expand All @@ -47,3 +55,6 @@ brews:
system "#{bin}/fctl version"
install: |
bin.install "fctl"
bash_completion.install "completions/fctl.bash" => "fctl"
zsh_completion.install "completions/fctl.zsh" => "_fctl"
fish_completion.install "completions/fctl.fish"
9 changes: 9 additions & 0 deletions components/fctl/scripts/completions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# scripts/completions.sh
set -e
rm -rf completions
mkdir completions

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

1 comment on commit 1d1fab2

@vercel
Copy link

@vercel vercel bot commented on 1d1fab2 Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.