Skip to content

Commit

Permalink
Autoload fish completions and fix Makefile (#645)
Browse files Browse the repository at this point in the history
* Change fish completion filename

why:
- Fish uses the filename of a completion file to determine which command
  the completions are for when autoloading them. The previous filename
  meant completions weren't being autoloaded.

* Use path package to build completion path

Path's are complicated and easy to get wrong. Let Go deal with it.
  • Loading branch information
Hawkbawk authored Apr 29, 2024
1 parent f94f882 commit c993e05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ clean:
rm ${PREFIX}/bin/dassume
rm ${PREFIX}/bin/dassume.fish

aws-credentials:
aws-credentials:
echo -e "\nAWS_ACCESS_KEY_ID=\"$$AWS_ACCESS_KEY_ID\"\nAWS_SECRET_ACCESS_KEY=\"$$AWS_SECRET_ACCESS_KEY\"\nAWS_SESSION_TOKEN=\"$$AWS_SESSION_TOKEN\"\nAWS_REGION=\"$$AWS_REGION\""

test-browser-binary:
Expand Down Expand Up @@ -49,11 +49,11 @@ ci-cli-all-platforms: test-binaries

## This will use the 'granted' binary and 'assume' symlink for dev build.
## Helpful to use dev build using 'granted' and 'assume' before release.
cli-act-prod: go-binary assume-binary
cli-act-prod: go-binary
mv ./bin/dgranted ${PREFIX}/bin/granted
ln -s granted ${PREFIX}/bin/dassumego
# replace references to "assumego" (the production binary) with "dassumego"
cat scripts/assume | sed 's/assumego/dassumego/g' > ${PREFIX}/bin/dassume && chmod +x ${PREFIX}/bin/dassume
cat scripts/assume.fish | sed 's/assumego/dassumego/g' > ${PREFIX}/bin/dassume.fish && chmod +x ${PREFIX}/bin/dassume.fish
mv ${PREFIX}/bin/dassume ${PREFIX}/bin/assume
mv ${PREFIX}/bin/dassume.fish ${PREFIX}/bin/assume.fish
mv ${PREFIX}/bin/dassume.fish ${PREFIX}/bin/assume.fish
2 changes: 1 addition & 1 deletion pkg/granted/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func installFishCompletions(c *cli.Context) error {
// try to fetch user home dir
user, _ := user.Current()

executableDir := user.HomeDir + "/.config/fish/completions/granted_completer_fish.fish"
executableDir := path.Join(user.HomeDir, ".config/fish/completions", fmt.Sprintf("%s.fish", c.App.Name))

// Try to create a file
err := os.WriteFile(executableDir, []byte(combinedOutput), 0600)
Expand Down

0 comments on commit c993e05

Please sign in to comment.